fix: check version #2
Workflow file for this run
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
| name: Build and Release | |
| on: | |
| push: | |
| tags: | |
| - "[0-9]+.[0-9]+.[0-9]+" | |
| permissions: | |
| contents: read | |
| packages: write | |
| id-token: write | |
| jobs: | |
| test: | |
| runs-on: ubuntu-24.04-arm | |
| name: Test | |
| steps: | |
| - name: Checkout Repository | |
| uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
| - name: Test | |
| uses: ./.github/workflows/composite/test | |
| check-version: | |
| runs-on: ubuntu-24.04-arm | |
| name: Check Version | |
| steps: | |
| - name: Checkout Repository | |
| uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
| - name: Check Greater Than latest | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| latest_version=$(gh release view --json tagName -q .tagName || echo "0.0.0") | |
| newest_version=$(printf "%s\n%s" "$latest_version" "${{ github.ref_name }}" | sort -V | tail -n1) | |
| if [[ "${{ github.ref_name }}" != "$newest_version" ]]; then | |
| echo "Tag is not newer than the latest release" >> /dev/stderr | |
| exit 1 | |
| fi | |
| - name: Check Backend Package Version | |
| run: | | |
| backend_version=$(awk -F' *= *' ' | |
| $0 ~ /^\[package\]/ { in_package=1; next } | |
| in_package && $1 ~ /^version$/ { | |
| gsub(/["'\'']/, "", $2); print $2; exit | |
| } | |
| ' Cargo.toml) | |
| if [[ "${{ github.ref_name }}" != "$backend_version" ]]; then | |
| echo "Backend package version does not match tag" >> /dev/stderr | |
| exit 1 | |
| fi | |
| build-arm64: | |
| runs-on: ubuntu-24.04-arm | |
| name: Build for arm64 | |
| needs: | |
| - test | |
| - check-version | |
| steps: | |
| - name: Checkout Repository | |
| uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
| - name: Build | |
| uses: ./.github/workflows/composite/build | |
| with: | |
| artifact-name: arm64 | |
| build-amd64: | |
| runs-on: ubuntu-24.04 | |
| name: Build for amd64 | |
| needs: | |
| - test | |
| - check-version | |
| steps: | |
| - name: Checkout Repository | |
| uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
| - name: Build | |
| uses: ./.github/workflows/composite/build | |
| with: | |
| artifact-name: amd64 | |
| publish: | |
| runs-on: ubuntu-24.04-arm | |
| name: Publish | |
| needs: | |
| - build-amd64 | |
| - build-arm64 | |
| steps: | |
| - name: Checkout Repository | |
| uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
| with: | |
| fetch-depth: 0 | |
| - name: Download arm64 Artifact | |
| uses: actions/download-artifact@abefc31eafcfbdf6c5336127c1346fdae79ff41c | |
| with: | |
| name: arm64 | |
| path: /tmp/koala-arm64 | |
| - name: Download amd64 Artifact | |
| uses: actions/download-artifact@abefc31eafcfbdf6c5336127c1346fdae79ff41c | |
| with: | |
| name: amd64 | |
| path: /tmp/koala-amd64 | |
| - name: Generate Changelog | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| latest_version=$(gh release view --json tagName -q .tagName || echo "") | |
| if [[ "$latest_version" == "" ]]; then | |
| git log --pretty=format:"%s" > /tmp/changelog.txt | |
| else | |
| latest_version_commit=$(git rev-parse "$latest_version") | |
| git log $latest_version_commit..${{ github.sha }} --pretty=format:"%s" > /tmp/changelog.txt | |
| fi | |
| - name: Publish | |
| uses: softprops/action-gh-release@6cbd405e2c4e67a21c47fa9e383d020e4e28b836 # 2.3.3 | |
| with: | |
| body_path: /tmp/changelog.txt | |
| files: | | |
| /tmp/koala-arm64 | |
| /tmp/koala-amd64 |