Skip to content

Release a new version #8

Release a new version

Release a new version #8

name: Release a new version
on:
workflow_dispatch:
jobs:
create-release:
name: Release a new version
runs-on: ubuntu-latest
steps:
- name: Generate a token
id: generate_token
uses: actions/create-github-app-token@v1
with:
app-id: ${{ secrets.HYPERSWITCH_BOT_APP_ID }}
private-key: ${{ secrets.HYPERSWITCH_BOT_APP_PRIVATE_KEY }}
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ steps.generate_token.outputs.token }}
- name: Install Rust
uses: dtolnay/rust-toolchain@master
with:
toolchain: stable 2 weeks ago
- name: Install cocogitto
uses: baptiste0928/[email protected]
with:
crate: cocogitto
version: 5.4.0
- name: Install git-cliff
uses: baptiste0928/[email protected]
with:
crate: git-cliff
version: 1.2.0
- name: Install changelog-gh-usernames
uses: baptiste0928/[email protected]
with:
crate: changelog-gh-usernames
git: https://github.com/SanchithHegde/changelog-gh-usernames
rev: dab6da3ff99dbbff8650c114984c4d8be5161ac8
- name: Set Git Configuration
shell: bash
run: |
git config --local user.name 'hyperswitch-bot[bot]'
git config --local user.email '148525504+hyperswitch-bot[bot]@users.noreply.github.com'
- name: Obtain previous and new tag information
shell: bash
# Only consider tags on current branch when setting PREVIOUS_TAG
run: |
PREVIOUS_TAG="$(git tag --sort='version:refname' --merged | tail --lines 1)"
if [[ "$(cog bump --auto --dry-run)" == *"No conventional commits for your repository that required a bump"* ]]; then
NEW_TAG="$(cog bump --patch --dry-run)"
else
NEW_TAG="$(cog bump --auto --dry-run)"
fi
echo "NEW_TAG=${NEW_TAG}" >> $GITHUB_ENV
echo "PREVIOUS_TAG=${PREVIOUS_TAG}" >> $GITHUB_ENV
- name: Update changelog and create tag
shell: bash
if: ${{ env.NEW_TAG != env.PREVIOUS_TAG }}
# Remove prefix 'v' from 'NEW_TAG' as cog bump --version expects only the version number
run: |
cog bump --version ${NEW_TAG#v}
- name: Push created commit and tag
shell: bash
if: ${{ env.NEW_TAG != env.PREVIOUS_TAG }}
run: |
git push
git push --tags
- name: Generate release notes and create GitHub release
shell: bash
if: ${{ env.NEW_TAG != env.PREVIOUS_TAG }}
env:
GITHUB_TOKEN: ${{ github.token }}
GH_TOKEN: ${{ steps.generate_token.outputs.token }}
# Need to consider commits inclusive of previous tag to generate diff link between versions.
# This would also then require us to remove the last few lines from the changelog.
run: |
git-cliff --config .github/git-cliff-release.toml "${PREVIOUS_TAG}^..${NEW_TAG}" | changelog-gh-usernames | sed "/## ${PREVIOUS_TAG#v}/,\$d" > release-notes.md
gh release create "${NEW_TAG}" --notes-file release-notes.md --verify-tag --title "Hyperswitch Card Vault ${NEW_TAG}"