Release #14
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: Release | |
| on: | |
| workflow_dispatch: | |
| branches: | |
| - master | |
| inputs: | |
| release_level: | |
| description: 'Release level' | |
| required: true | |
| type: choice | |
| options: | |
| - alpha | |
| - beta | |
| - patch | |
| - minor | |
| - major | |
| jobs: | |
| release: | |
| runs-on: ubuntu-latest-arm-64 | |
| permissions: | |
| contents: write # Required for pushing commits and tags | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v5 | |
| with: | |
| fetch-depth: 0 | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| persist-credentials: true | |
| - name: Setup Rust | |
| uses: dtolnay/rust-toolchain@stable | |
| - name: Install cargo-release | |
| run: cargo install cargo-release | |
| - name: Install git-cliff | |
| run: cargo install git-cliff | |
| - name: Check compilation | |
| run: cargo check --all-features | |
| - name: Get GitHub App token (for bpx-api-client) | |
| id: app-token | |
| uses: actions/create-github-app-token@v2 | |
| with: | |
| app-id: ${{ secrets.BACKPACK_CI_APP_ID }} | |
| private-key: ${{ secrets.BACKPACK_CI_APP_PRIVATE_KEY }} | |
| owner: backpack-exchange | |
| repositories: | | |
| bpx-api-client | |
| - name: Configure git (disable signing in CI) | |
| run: | | |
| git config --global user.email "bot@backpack.exchange" | |
| git config --global user.name "backpack-exchange[bot]" | |
| git config --global credential.helper cache | |
| git config --global commit.gpgsign false | |
| - name: Clone bpx-api-client repository | |
| env: | |
| APP_TOKEN: ${{ steps.app-token.outputs.token }} | |
| run: | | |
| git clone "https://x-access-token:${APP_TOKEN}@github.com/backpack-exchange/bpx-api-client.git" bpx-api-client | |
| - name: Release | |
| env: | |
| APP_TOKEN: ${{ steps.app-token.outputs.token }} | |
| run: | | |
| cd bpx-api-client | |
| git remote set-url origin "https://x-access-token:${APP_TOKEN}@github.com/backpack-exchange/bpx-api-client.git" | |
| # Run cargo release to update the version | |
| cargo release version ${{ github.event.inputs.release_level }} --execute --no-confirm | |
| # Extract the new version from Cargo.toml | |
| NEW_VERSION=$(grep "^version" Cargo.toml | head -1 | cut -d'"' -f2) | |
| # Generate the CHANGELOG | |
| git tag v${NEW_VERSION} | |
| git-cliff -o CHANGELOG.md | |
| git tag --delete v${NEW_VERSION} | |
| # Commit the changes | |
| git add -A | |
| git commit -m "chore(release) v${NEW_VERSION}" | |
| # Tag the release | |
| git tag v${NEW_VERSION} | |
| # Push | |
| CURRENT_BRANCH="$(git rev-parse --abbrev-ref HEAD || echo master)" | |
| git push origin "HEAD:${CURRENT_BRANCH}" --tags | |
| # Publish | |
| cargo publish --token ${{ secrets.CARGO_REGISTRY_TOKEN }} |