testing new workflow in dev branch!
This commit is contained in:
+124
-13
@@ -1,25 +1,37 @@
|
||||
name: Compile to Binary
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ main, master, dev ]
|
||||
branches: [ "*" ]
|
||||
pull_request:
|
||||
branches: [ main, master ]
|
||||
branches: [ "*" ]
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
|
||||
build-linux:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Check if Rust/Cargo is already installed
|
||||
id: rust-check-linux
|
||||
run: |
|
||||
if command -v cargo &>/dev/null; then
|
||||
echo "installed=true" >> $GITHUB_OUTPUT
|
||||
echo "Cargo found: $(cargo --version)"
|
||||
else
|
||||
echo "installed=false" >> $GITHUB_OUTPUT
|
||||
fi
|
||||
|
||||
- name: Install Rust
|
||||
if: steps.rust-check-linux.outputs.installed == 'false'
|
||||
uses: dtolnay/rust-toolchain@stable
|
||||
with:
|
||||
targets: x86_64-unknown-linux-gnu
|
||||
|
||||
- name: Add target (if Rust was pre-installed)
|
||||
if: steps.rust-check-linux.outputs.installed == 'true'
|
||||
run: rustup target add x86_64-unknown-linux-gnu
|
||||
|
||||
- name: Cache Cargo
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
@@ -42,21 +54,34 @@ jobs:
|
||||
name: http-rs-linux-x86_64
|
||||
path: artifacts/http-rs-linux-x86_64
|
||||
|
||||
|
||||
build-linux-musl:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Install musl tools
|
||||
run: sudo apt-get update && sudo apt-get install -y musl-tools
|
||||
|
||||
- name: Check if Rust/Cargo is already installed
|
||||
id: rust-check-musl
|
||||
run: |
|
||||
if command -v cargo &>/dev/null; then
|
||||
echo "installed=true" >> $GITHUB_OUTPUT
|
||||
echo "Cargo found: $(cargo --version)"
|
||||
else
|
||||
echo "installed=false" >> $GITHUB_OUTPUT
|
||||
fi
|
||||
|
||||
- name: Install Rust
|
||||
if: steps.rust-check-musl.outputs.installed == 'false'
|
||||
uses: dtolnay/rust-toolchain@stable
|
||||
with:
|
||||
targets: x86_64-unknown-linux-musl
|
||||
|
||||
- name: Add target (if Rust was pre-installed)
|
||||
if: steps.rust-check-musl.outputs.installed == 'true'
|
||||
run: rustup target add x86_64-unknown-linux-musl
|
||||
|
||||
- name: Cache Cargo
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
@@ -79,22 +104,33 @@ jobs:
|
||||
name: http-rs-linux-musl-x86_64
|
||||
path: artifacts/http-rs-linux-musl-x86_64
|
||||
|
||||
|
||||
build-windows:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Install MinGW
|
||||
run: sudo apt-get update && sudo apt-get install -y gcc-mingw-w64-x86-64
|
||||
|
||||
- name: Check if Rust/Cargo is already installed
|
||||
id: rust-check-windows
|
||||
run: |
|
||||
if command -v cargo &>/dev/null; then
|
||||
echo "installed=true" >> $GITHUB_OUTPUT
|
||||
echo "Cargo found: $(cargo --version)"
|
||||
else
|
||||
echo "installed=false" >> $GITHUB_OUTPUT
|
||||
fi
|
||||
|
||||
- name: Install Rust
|
||||
if: steps.rust-check-windows.outputs.installed == 'false'
|
||||
uses: dtolnay/rust-toolchain@stable
|
||||
with:
|
||||
targets: x86_64-pc-windows-gnu
|
||||
|
||||
- name: Install MinGW
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y gcc-mingw-w64-x86-64
|
||||
- name: Add target (if Rust was pre-installed)
|
||||
if: steps.rust-check-windows.outputs.installed == 'true'
|
||||
run: rustup target add x86_64-pc-windows-gnu
|
||||
|
||||
- name: Cache Cargo
|
||||
uses: actions/cache@v3
|
||||
@@ -117,3 +153,78 @@ jobs:
|
||||
with:
|
||||
name: http-rs-windows-x86_64
|
||||
path: artifacts/http-rs-windows-x86_64.exe
|
||||
|
||||
release:
|
||||
runs-on: ubuntu-latest
|
||||
needs: [build-linux, build-linux-musl, build-windows]
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 1
|
||||
|
||||
- name: Ensure jq is installed
|
||||
run: |
|
||||
if ! command -v jq &>/dev/null; then
|
||||
sudo apt-get update && sudo apt-get install -y jq
|
||||
else
|
||||
echo "jq already present: $(jq --version)"
|
||||
fi
|
||||
|
||||
- name: Gather commit info
|
||||
id: info
|
||||
run: |
|
||||
SHORT_SHA=$(git rev-parse --short HEAD)
|
||||
BRANCH="${{ gitea.ref_name }}"
|
||||
COMMIT_MSG=$(git log -1 --format="%s")
|
||||
FULL_MSG=$(git log -1 --format="%B")
|
||||
|
||||
echo "short_sha=$SHORT_SHA" >> $GITHUB_OUTPUT
|
||||
echo "branch=$BRANCH" >> $GITHUB_OUTPUT
|
||||
echo "commit_msg=$COMMIT_MSG" >> $GITHUB_OUTPUT
|
||||
echo "full_msg<<EOF" >> $GITHUB_OUTPUT
|
||||
echo "$FULL_MSG" >> $GITHUB_OUTPUT
|
||||
echo "EOF" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Download all artifacts
|
||||
uses: actions/download-artifact@v3
|
||||
with:
|
||||
path: release-artifacts
|
||||
|
||||
- name: Create Gitea release and upload assets
|
||||
env:
|
||||
GITEA_TOKEN: ${{ secrets.HTTP_RS_RELEASE_PUSH }}
|
||||
SERVER_URL: ${{ gitea.server_url }}
|
||||
REPO: ${{ gitea.repository }}
|
||||
TAG: ${{ steps.info.outputs.short_sha }}-${{ steps.info.outputs.branch }}
|
||||
RELEASE_NAME: "${{ steps.info.outputs.short_sha }}:${{ steps.info.outputs.branch }} - ${{ steps.info.outputs.commit_msg }}"
|
||||
BODY: ${{ steps.info.outputs.full_msg }}
|
||||
run: |
|
||||
RELEASE_RESPONSE=$(curl -s -X POST \
|
||||
"$SERVER_URL/api/v1/repos/$REPO/releases" \
|
||||
-H "Authorization: token $GITEA_TOKEN" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d "$(jq -n \
|
||||
--arg tag "$TAG" \
|
||||
--arg name "$RELEASE_NAME" \
|
||||
--arg body "$BODY" \
|
||||
'{tag_name: $tag, name: $name, body: $body, draft: false, prerelease: false}'
|
||||
)")
|
||||
|
||||
RELEASE_ID=$(echo "$RELEASE_RESPONSE" | jq -r '.id')
|
||||
echo "Created release ID: $RELEASE_ID"
|
||||
|
||||
if [ -z "$RELEASE_ID" ] || [ "$RELEASE_ID" = "null" ]; then
|
||||
echo "Failed to create release:"
|
||||
echo "$RELEASE_RESPONSE"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
find release-artifacts -type f | while read FILE; do
|
||||
FILENAME=$(basename "$FILE")
|
||||
echo "Uploading $FILENAME..."
|
||||
curl -s -X POST \
|
||||
"$SERVER_URL/api/v1/repos/$REPO/releases/$RELEASE_ID/assets?name=$FILENAME" \
|
||||
-H "Authorization: token $GITEA_TOKEN" \
|
||||
-H "Content-Type: application/octet-stream" \
|
||||
--data-binary @"$FILE"
|
||||
done
|
||||
|
||||
Reference in New Issue
Block a user