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