-
Notifications
You must be signed in to change notification settings - Fork 18
ci: add goreleaser #427
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
andriygm
wants to merge
6
commits into
main
Choose a base branch
from
ci/goreleaser
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
ci: add goreleaser #427
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
28d1989
feat: use goreleaser for release + snapshots
andriygm 3f0a57d
add attestations permission to snapshot workflow
andriygm f823488
remove explicit glibc version from gnu targets
andriygm 8790fff
add --release flag to goreleaser build targets
andriygm 6448146
fix smoke test to find archive dynamically
andriygm 9bd1b3b
use wrapper script to target glibc 2.28 with latest zig
andriygm File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| #!/bin/bash | ||
| # Wrapper around cargo-zigbuild that appends .2.28 to linux-gnu targets | ||
| # to ensure glibc 2.28 compatibility (RHEL 8 / AlmaLinux 8). | ||
| args=() | ||
| for arg in "$@"; do | ||
| args+=("${arg/unknown-linux-gnu/unknown-linux-gnu.2.28}") | ||
| done | ||
| exec cargo-zigbuild "${args[@]}" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,181 @@ | ||
| name: Build | ||
|
|
||
| on: | ||
| workflow_call: | ||
| inputs: | ||
| release: | ||
| required: true | ||
| type: boolean | ||
| default: false | ||
| secrets: | ||
| GORELEASER_KEY: | ||
| required: true | ||
| TAP_GITHUB_TOKEN: | ||
| required: false | ||
|
|
||
| permissions: | ||
| contents: write | ||
| attestations: write | ||
| id-token: write | ||
|
|
||
| jobs: | ||
| # Split step - build binaries on each platform | ||
| prepare: | ||
| name: Prepare | ||
| strategy: | ||
| matrix: | ||
| include: | ||
| - os: ubuntu-22.04 | ||
| platform: linux | ||
| - os: macos-latest | ||
| platform: darwin | ||
| - os: windows-latest | ||
| platform: windows | ||
| runs-on: ${{ matrix.os }} | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| fetch-depth: 0 | ||
|
|
||
| - name: Cache Rust | ||
| uses: Swatinem/rust-cache@v2 | ||
|
|
||
| - name: Setup Zig | ||
| uses: mlugg/setup-zig@v2 | ||
|
|
||
| - name: Install cargo-binstall | ||
| uses: cargo-bins/cargo-binstall@main | ||
|
|
||
| - name: Install cargo-zigbuild | ||
| run: cargo binstall cargo-zigbuild | ||
|
|
||
| - name: Install musl tools (Linux) | ||
| if: ${{ contains(matrix.os, 'ubuntu') }} | ||
| run: | | ||
| sudo apt-get update -y | ||
| sudo apt-get install -y musl-tools musl-dev | ||
|
|
||
| # Set release flags | ||
| - name: Set release flags | ||
| if: inputs.release != true | ||
| run: | | ||
| echo "release_flags=--snapshot" >> $GITHUB_ENV | ||
| shell: bash | ||
|
|
||
| - name: Run GoReleaser Split | ||
| uses: goreleaser/goreleaser-action@v6 | ||
| with: | ||
| distribution: goreleaser-pro | ||
| version: latest | ||
| args: release --clean --split ${{ env.release_flags }} | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }} | ||
|
|
||
| # Debug - list files in dist directory | ||
| - name: List files in dist directory | ||
| run: find dist -type f | sort | ||
| shell: bash | ||
|
|
||
| - name: Upload build artifacts | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: build-${{ matrix.platform }} | ||
| path: dist/${{ matrix.platform }} | ||
| retention-days: 1 | ||
|
|
||
| # Smoke test - verify the linux-gnu binary runs on AlmaLinux 8 | ||
| smoke-test: | ||
| name: Smoke Test (AlmaLinux 8) | ||
| needs: prepare | ||
| runs-on: ubuntu-latest | ||
| container: | ||
| image: almalinux:8 | ||
| steps: | ||
| - name: Download linux build artifacts | ||
| uses: actions/download-artifact@v4 | ||
| with: | ||
| name: build-linux | ||
| path: dist/linux | ||
|
|
||
| - name: List artifact files | ||
| run: find dist -type f | sort | ||
|
|
||
| - name: Extract and test binary | ||
| run: | | ||
| ARCHIVE=$(find dist -name "rv_Linux_x86_64.tar.gz" -type f | head -1) | ||
| echo "Found archive: $ARCHIVE" | ||
| tar -xzf "$ARCHIVE" -C /usr/local/bin | ||
| rv --version | ||
| rv --help | ||
|
|
||
| # Merge step - combine artifacts and create release | ||
| release: | ||
| name: Release | ||
| needs: [prepare, smoke-test] | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| fetch-depth: 0 | ||
|
|
||
| # Download all build artifacts | ||
| - name: Download all build artifacts | ||
| uses: actions/download-artifact@v4 | ||
| with: | ||
| pattern: build-* | ||
| path: dist | ||
| merge-multiple: false | ||
|
|
||
| # Rename folders to remove build- prefix | ||
| - name: Rename artifact folders | ||
| run: | | ||
| cd dist | ||
| for dir in build-*; do | ||
| if [ -d "$dir" ]; then | ||
| mv "$dir" "${dir#build-}" | ||
| fi | ||
| done | ||
|
|
||
| # Debug: List downloaded files | ||
| - name: List artifact files | ||
| run: find dist -type f | sort | ||
|
|
||
| # Set release flags | ||
| - name: Set release flags | ||
| if: inputs.release != true | ||
| run: | | ||
| echo "release_flags=--snapshot" >> $GITHUB_ENV | ||
|
|
||
| # Continue with merge | ||
| - name: Run GoReleaser Merge | ||
| uses: goreleaser/goreleaser-action@v6 | ||
| with: | ||
| distribution: goreleaser-pro | ||
| version: latest | ||
| args: continue --merge | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }} | ||
| TAP_GITHUB_TOKEN: ${{ secrets.TAP_GITHUB_TOKEN }} | ||
|
|
||
| # Pull build artifacts up to the root dist directory for easier access | ||
| - name: Pull build artifacts up | ||
| run: | | ||
| find dist -type f -name "rv_*" -not -path "*/\.*" -not -path "dist/rv_*" -exec mv {} dist/ \; || true | ||
| ls -la dist/ | ||
|
|
||
| - name: Attest Build Provenance | ||
| if: inputs.release == true | ||
| uses: actions/attest@v2 | ||
| with: | ||
| subject-checksums: dist/checksums.txt | ||
|
|
||
| - name: Upload release artifacts | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: release | ||
| path: dist | ||
| retention-days: 1 | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does that make a difference?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it could go either way, I usually like to cache deps in case I need to make a patch. if the deps all change it's effectively useless.