From 1277064c2585b9f51f7a1373914df4232fe5a896 Mon Sep 17 00:00:00 2001 From: jseam2 Date: Fri, 27 Feb 2026 04:04:34 +0800 Subject: [PATCH] ci: updated --- .github/workflows/build-release.yml | 94 ++++++++++++++++++++++++----- .github/workflows/tagging.yml | 55 ----------------- 2 files changed, 78 insertions(+), 71 deletions(-) delete mode 100644 .github/workflows/tagging.yml diff --git a/.github/workflows/build-release.yml b/.github/workflows/build-release.yml index c369092..1daaaf9 100644 --- a/.github/workflows/build-release.yml +++ b/.github/workflows/build-release.yml @@ -6,8 +6,50 @@ on: - main jobs: + bump-version: + runs-on: ubuntu-latest + permissions: + contents: write + outputs: + new_tag: ${{ steps.tag_version.outputs.new_tag }} + should_release: ${{ steps.tag_version.outputs.new_tag != '' }} + + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Bump version and push tag + id: tag_version + uses: mathieudutour/github-tag-action@v6.2 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + + - name: Set Cargo.toml version to match github tag + if: steps.tag_version.outputs.new_tag != '' + shell: bash + env: + RELEASE_TAG: ${{ steps.tag_version.outputs.new_tag }} + run: | + VERSION=${RELEASE_TAG#v} + sed -i 's/^version = ".*"/version = "'"$VERSION"'"/' Cargo.toml + + - name: Commit files and update tag + if: steps.tag_version.outputs.new_tag != '' + env: + RELEASE_TAG: ${{ steps.tag_version.outputs.new_tag }} + run: | + git config --local user.email "github-actions[bot]@users.noreply.github.com" + git config --local user.name "github-actions[bot]" + git add Cargo.toml + git commit -m "ci: update Cargo.toml version to $RELEASE_TAG" || echo "No changes to commit" + git tag -f $RELEASE_TAG + git push origin $RELEASE_TAG --force + test: name: Test on ${{ matrix.os }} + needs: bump-version + if: needs.bump-version.outputs.should_release == 'true' runs-on: ${{ matrix.os }} strategy: matrix: @@ -54,6 +96,8 @@ jobs: test-solidity: name: Test Solidity + needs: bump-version + if: needs.bump-version.outputs.should_release == 'true' runs-on: ubuntu-latest steps: @@ -82,6 +126,8 @@ jobs: lint: name: Lint Rust + needs: bump-version + if: needs.bump-version.outputs.should_release == 'true' runs-on: ubuntu-latest steps: @@ -210,9 +256,9 @@ jobs: create-release: name: Create Release - needs: build + needs: [bump-version, build] runs-on: ubuntu-latest - if: github.ref == 'refs/heads/main' + if: needs.bump-version.outputs.should_release == 'true' steps: - name: Checkout code @@ -223,28 +269,44 @@ jobs: with: path: artifacts + - name: Rename binaries with proper names + run: | + mv artifacts/safepaw-linux-x86_64/safepaw artifacts/safepaw-linux-x86_64/safepaw-linux-x86_64 + mv artifacts/safepaw-linux-aarch64/safepaw artifacts/safepaw-linux-aarch64/safepaw-linux-aarch64 + mv artifacts/safepaw-macos-x86_64/safepaw artifacts/safepaw-macos-x86_64/safepaw-macos-x86_64 + mv artifacts/safepaw-macos-aarch64/safepaw artifacts/safepaw-macos-aarch64/safepaw-macos-aarch64 + mv artifacts/safepaw-windows-x86_64/safepaw.exe artifacts/safepaw-windows-x86_64/safepaw-windows-x86_64.exe + - name: Create GitHub Release uses: softprops/action-gh-release@v2 with: - tag_name: build-${{ github.run_number }} - name: Build ${{ github.run_number }} + tag_name: ${{ needs.bump-version.outputs.new_tag }} + name: Release ${{ needs.bump-version.outputs.new_tag }} body: | - Automated build from commit ${{ github.sha }} + Release ${{ needs.bump-version.outputs.new_tag }} - **Changes:** ${{ github.event.head_commit.message }} + **Commit:** ${{ github.sha }} ## Binaries - - Linux x86_64 - - Linux ARM64 - - macOS x86_64 (Intel) - - macOS ARM64 (Apple Silicon) - - Windows x86_64 + + ### Linux (glibc-based distributions: Ubuntu, Debian, Fedora, etc.) + - `safepaw-linux-x86_64` - Linux x86_64 (64-bit Intel/AMD) + - `safepaw-linux-aarch64` - Linux ARM64 (64-bit ARM) + + ### macOS + - `safepaw-macos-x86_64` - macOS Intel (x86_64) + - `safepaw-macos-aarch64` - macOS Apple Silicon (ARM64) + + ### Windows + - `safepaw-windows-x86_64.exe` - Windows x86_64 (64-bit) + + **Note:** Linux binaries are dynamically linked against glibc and may not work on musl-based distributions (Alpine Linux). If you need musl support, please build from source. files: | - artifacts/safepaw-linux-x86_64/safepaw - artifacts/safepaw-linux-aarch64/safepaw - artifacts/safepaw-macos-x86_64/safepaw - artifacts/safepaw-macos-aarch64/safepaw - artifacts/safepaw-windows-x86_64/safepaw.exe + artifacts/safepaw-linux-x86_64/safepaw-linux-x86_64 + artifacts/safepaw-linux-aarch64/safepaw-linux-aarch64 + artifacts/safepaw-macos-x86_64/safepaw-macos-x86_64 + artifacts/safepaw-macos-aarch64/safepaw-macos-aarch64 + artifacts/safepaw-windows-x86_64/safepaw-windows-x86_64.exe draft: false prerelease: false env: diff --git a/.github/workflows/tagging.yml b/.github/workflows/tagging.yml deleted file mode 100644 index bbd9db8..0000000 --- a/.github/workflows/tagging.yml +++ /dev/null @@ -1,55 +0,0 @@ -name: Bump Version - -on: - push: - branches: ["main"] - -jobs: - bump-version: - runs-on: ubuntu-latest - permissions: - contents: write - - steps: - - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 #v4.2.2 - with: - persist-credentials: false - - name: Bump version and push tag - id: tag_version - uses: mathieudutour/github-tag-action@a22cf08638b34d5badda920f9daf6e72c477b07b #v6.2 - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - - - name: Set Cargo.toml version to match github tag for docs - shell: bash - env: - RELEASE_TAG: ${{ steps.tag_version.outputs.new_tag }} - run: | - mv docs/python/src/conf.py docs/python/src/conf.py.orig - sed "s/0\\.0\\.0/${RELEASE_TAG//v}/" docs/python/src/conf.py.orig >docs/python/src/conf.py - rm docs/python/src/conf.py.orig - mv docs/python/requirements-docs.txt docs/python/requirements-docs.txt.orig - sed "s/0\\.0\\.0/${RELEASE_TAG//v}/" docs/python/requirements-docs.txt.orig >docs/python/requirements-docs.txt - rm docs/python/requirements-docs.txt.orig - - - name: Commit files and create tag - env: - RELEASE_TAG: ${{ steps.tag_version.outputs.new_tag }} - run: | - git config --local user.email "github-actions[bot]@users.noreply.github.com" - git config --local user.name "github-actions[bot]" - git fetch --tags - git checkout -b release-$RELEASE_TAG - git add . - git commit -m "ci: update version string in docs" - git tag -d $RELEASE_TAG - git tag $RELEASE_TAG - - - name: Push changes - uses: ad-m/github-push-action@77c5b412c50b723d2a4fbc6d71fb5723bcd439aa #master - env: - RELEASE_TAG: ${{ steps.tag_version.outputs.new_tag }} - with: - branch: release-${{ steps.tag_version.outputs.new_tag }} - force: true - tags: true \ No newline at end of file