Update .forgejo/workflows/pgo-binary.yml

This commit is contained in:
gigirassy
2026-08-18 01:11:21 +02:00
parent 5a0b69fba8
commit 695674a0bd
+36 -75
View File
@@ -1,14 +1,10 @@
name: Build and Release name: Build and Release
on: on:
push: push:
tags: tags:
- "v*" - "v*"
permissions:
contents: write
env: env:
LINUX_TARGET: x86_64-unknown-linux-musl LINUX_TARGET: x86_64-unknown-linux-musl
WINDOWS_TARGET: x86_64-pc-windows-gnu WINDOWS_TARGET: x86_64-pc-windows-gnu
@@ -36,7 +32,7 @@ jobs:
binutils \ binutils \
coreutils coreutils
- name: Install Rust targets and LLVM tools - name: Install Rust target and LLVM tools
run: | run: |
rustup target add "$LINUX_TARGET" rustup target add "$LINUX_TARGET"
rustup component add llvm-tools-preview rustup component add llvm-tools-preview
@@ -50,11 +46,9 @@ jobs:
LLVM_BIN="$SYSROOT/lib/rustlib/$HOST/bin" LLVM_BIN="$SYSROOT/lib/rustlib/$HOST/bin"
test -x "$LLVM_BIN/llvm-profdata" test -x "$LLVM_BIN/llvm-profdata"
echo "LLVM_BIN=$LLVM_BIN" >> "$GITHUB_OUTPUT" echo "LLVM_BIN=$LLVM_BIN" >> "$GITHUB_OUTPUT"
- name: Build instrumented binary - name: Build instrumented binary
shell: sh
run: | run: |
rm -rf /tmp/riptide-pgo rm -rf /tmp/riptide-pgo
mkdir -p /tmp/riptide-pgo mkdir -p /tmp/riptide-pgo
@@ -72,10 +66,7 @@ jobs:
chmod +x /tmp/riptide-pgo/riptide chmod +x /tmp/riptide-pgo/riptide
file /tmp/riptide-pgo/riptide
- name: Train PGO profile - name: Train PGO profile
shell: sh
env: env:
LLVM_PROFILE_FILE: /tmp/riptide-pgo/%m-%p.profraw LLVM_PROFILE_FILE: /tmp/riptide-pgo/%m-%p.profraw
run: | run: |
@@ -89,14 +80,13 @@ jobs:
test -s /tmp/pgo-urls.txt test -s /tmp/pgo-urls.txt
echo "Training input produced:" echo "Training input:"
wc -l /tmp/pgo-urls.txt wc -l /tmp/pgo-urls.txt
echo "Generated profiles:" echo "Generated profiles:"
find /tmp/riptide-pgo -name '*.profraw' -type f -print find /tmp/riptide-pgo -name '*.profraw' -type f -print
- name: Merge PGO profiles - name: Merge PGO profiles
shell: sh
run: | run: |
"${{ steps.llvm.outputs.LLVM_BIN }}/llvm-profdata" merge \ "${{ steps.llvm.outputs.LLVM_BIN }}/llvm-profdata" merge \
-o /tmp/riptide-pgo.profdata \ -o /tmp/riptide-pgo.profdata \
@@ -105,7 +95,6 @@ jobs:
test -s /tmp/riptide-pgo.profdata test -s /tmp/riptide-pgo.profdata
- name: Build optimized Linux binary - name: Build optimized Linux binary
shell: sh
run: | run: |
RUSTFLAGS="\ RUSTFLAGS="\
-C target-feature=+crt-static \ -C target-feature=+crt-static \
@@ -115,25 +104,21 @@ jobs:
--target "$LINUX_TARGET" --target "$LINUX_TARGET"
mkdir -p dist mkdir -p dist
cp \ cp \
"target/$LINUX_TARGET/release/riptide" \ "target/$LINUX_TARGET/release/riptide" \
dist/riptide dist/riptide
chmod +x dist/riptide chmod +x dist/riptide
- name: Verify Linux binary - name: Verify static binary
shell: sh
run: | run: |
file dist/riptide file dist/riptide
if readelf -l dist/riptide | grep -q 'INTERP'; then if readelf -l dist/riptide | grep -q 'INTERP'; then
echo "ERROR: riptide has a dynamic ELF interpreter" echo "ERROR: binary has a dynamic ELF interpreter"
exit 1 exit 1
fi fi
echo "Static musl binary verified."
- name: Smoke test - name: Smoke test
run: | run: |
./dist/riptide --help ./dist/riptide --help
@@ -155,7 +140,7 @@ jobs:
- name: Checkout repository - name: Checkout repository
uses: actions/checkout@v4 uses: actions/checkout@v4
- name: Install Windows cross-compiler - name: Install Windows cross compiler
run: | run: |
apk add --no-cache \ apk add --no-cache \
mingw-w64-gcc \ mingw-w64-gcc \
@@ -167,28 +152,20 @@ jobs:
rustup target add "$WINDOWS_TARGET" rustup target add "$WINDOWS_TARGET"
- name: Build Windows binary - name: Build Windows binary
shell: sh
run: | run: |
cargo build \ cargo build \
--release \ --release \
--target "$WINDOWS_TARGET" --target "$WINDOWS_TARGET"
mkdir -p dist mkdir -p dist
cp \ cp \
"target/$WINDOWS_TARGET/release/riptide.exe" \ "target/$WINDOWS_TARGET/release/riptide.exe" \
dist/riptide.exe dist/riptide.exe
- name: Verify Windows binary - name: Verify Windows binary
shell: sh
run: | run: |
file dist/riptide.exe file dist/riptide.exe
- name: Smoke test
shell: sh
run: |
test -s dist/riptide.exe
- name: Upload Windows binary - name: Upload Windows binary
uses: actions/upload-artifact@v4 uses: actions/upload-artifact@v4
with: with:
@@ -225,28 +202,16 @@ jobs:
name: riptide-windows name: riptide-windows
path: release path: release
- name: Make binaries executable
run: |
chmod 755 release/riptide
chmod 644 release/riptide.exe
- name: Calculate checksums - name: Calculate checksums
id: checksum id: checksum
shell: sh
run: | run: |
LINUX_SHA="$(sha256sum release/riptide | awk '{print $1}')" LINUX_SHA="$(sha256sum release/riptide | awk '{print $1}')"
WINDOWS_SHA="$(sha256sum release/riptide.exe | awk '{print $1}')" WINDOWS_SHA="$(sha256sum release/riptide.exe | awk '{print $1}')"
printf '%s\n' "$LINUX_SHA" echo "LINUX_SHA=$LINUX_SHA" >> "$GITHUB_OUTPUT"
printf '%s\n' "$WINDOWS_SHA" echo "WINDOWS_SHA=$WINDOWS_SHA" >> "$GITHUB_OUTPUT"
{ - name: Create Forgejo release
echo "LINUX_SHA=$LINUX_SHA"
echo "WINDOWS_SHA=$WINDOWS_SHA"
} >> "$GITHUB_OUTPUT"
- name: Create release
shell: sh
env: env:
FORGEJO_TOKEN: ${{ secrets.FORGEJO_TOKEN }} FORGEJO_TOKEN: ${{ secrets.FORGEJO_TOKEN }}
REPO: ${{ github.repository }} REPO: ${{ github.repository }}
@@ -264,56 +229,52 @@ jobs:
} }
EOF EOF
RELEASE_JSON="$( curl -fsSL \
curl -fsSL \ -X POST \
-X POST \ -H "Authorization: token $FORGEJO_TOKEN" \
-H "Authorization: token $FORGEJO_TOKEN" \ -H "Content-Type: application/json" \
-H "Content-Type: application/json" \ "https://codeberg.org/api/v1/repos/$REPO/releases" \
"https://codeberg.org/api/v1/repos/$REPO/releases" \ --data-binary @release.json
--data-binary @release.json
)"
RELEASE_ID="$(printf '%s' "$RELEASE_JSON" | jq -r '.id')" - name: Get release ID
id: release
test "$RELEASE_ID" != "null"
test -n "$RELEASE_ID"
echo "Created release ID: $RELEASE_ID"
- name: Upload Linux binary
shell: sh
env: env:
FORGEJO_TOKEN: ${{ secrets.FORGEJO_TOKEN }} FORGEJO_TOKEN: ${{ secrets.FORGEJO_TOKEN }}
REPO: ${{ github.repository }} REPO: ${{ github.repository }}
TAG: ${{ github.ref_name }} TAG: ${{ github.ref_name }}
run: |
RELEASE_ID="$(
curl -fsSL \
-H "Authorization: token $FORGEJO_TOKEN" \
"https://codeberg.org/api/v1/repos/$REPO/releases/tags/$TAG" |
jq -r '.id'
)"
test "$RELEASE_ID" != "null"
echo "id=$RELEASE_ID" >> "$GITHUB_OUTPUT"
- name: Upload Linux binary
env:
FORGEJO_TOKEN: ${{ secrets.FORGEJO_TOKEN }}
REPO: ${{ github.repository }}
RELEASE_ID: ${{ steps.release.outputs.id }}
run: | run: |
curl -fsSL \ curl -fsSL \
-X POST \ -X POST \
-H "Authorization: token $FORGEJO_TOKEN" \ -H "Authorization: token $FORGEJO_TOKEN" \
-H "Content-Type: application/octet-stream" \ -H "Content-Type: application/octet-stream" \
--data-binary @release/riptide \ --data-binary @release/riptide \
"https://codeberg.org/api/v1/repos/$REPO/releases/$( \ "https://codeberg.org/api/v1/repos/$REPO/releases/$RELEASE_ID/assets?name=riptide"
curl -fsSL \
-H "Authorization: token $FORGEJO_TOKEN" \
"https://codeberg.org/api/v1/repos/$REPO/releases/tags/$TAG" |
jq -r '.id'
)/assets?name=riptide"
- name: Upload Windows binary - name: Upload Windows binary
shell: sh
env: env:
FORGEJO_TOKEN: ${{ secrets.FORGEJO_TOKEN }} FORGEJO_TOKEN: ${{ secrets.FORGEJO_TOKEN }}
REPO: ${{ github.repository }} REPO: ${{ github.repository }}
TAG: ${{ github.ref_name }} RELEASE_ID: ${{ steps.release.outputs.id }}
run: | run: |
curl -fsSL \ curl -fsSL \
-X POST \ -X POST \
-H "Authorization: token $FORGEJO_TOKEN" \ -H "Authorization: token $FORGEJO_TOKEN" \
-H "Content-Type: application/octet-stream" \ -H "Content-Type: application/octet-stream" \
--data-binary @release/riptide.exe \ --data-binary @release/riptide.exe \
"https://codeberg.org/api/v1/repos/$REPO/releases/$( \ "https://codeberg.org/api/v1/repos/$REPO/releases/$RELEASE_ID/assets?name=riptide.exe"
curl -fsSL \
-H "Authorization: token $FORGEJO_TOKEN" \
"https://codeberg.org/api/v1/repos/$REPO/releases/tags/$TAG" |
jq -r '.id'
)/assets?name=riptide.exe"