Release #37
This file contains 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: | |
inputs: | |
bumpType: | |
description: Semver bump type to use ("major"/"minor"/"patch") | |
required: true | |
default: patch | |
jobs: | |
release: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: '0' | |
submodules: recursive | |
- id: release | |
uses: anothrNick/[email protected] | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
DEFAULT_BUMP: ${{ github.event.inputs.bumpType }} | |
TAG_CONTEXT: branch | |
RELEASE_BRANCHES: main,releases.* | |
WITH_V: true | |
DRY_RUN: true | |
- id: read_toml | |
uses: SebRollen/[email protected] | |
with: | |
file: 'Cargo.toml' | |
field: 'package.version' | |
- name: match toml with tag | |
run: | | |
new_tag=${{steps.release.outputs.new_tag}} | |
new_tag="${new_tag:1}" | |
if [ "${{steps.read_toml.outputs.value}}" != "$new_tag" ]; then | |
echo "New Release Tag is $new_tag" | |
echo "Cargo.toml Tag is ${{steps.read_toml.outputs.value}}" | |
echo "Update Cargo.toml and Cargo.lock and try again" | |
exit 1 | |
fi | |
- id: parsed-release | |
uses: booxmedialtd/ws-action-parse-semver@v1 | |
with: | |
input_string: ${{ steps.release.outputs.tag }} | |
- name: Generate release | |
run: | | |
new_release_branch="" | |
if [ "${{ github.ref }}" = "refs/heads/main" ]; then | |
if [ "${{ github.event.inputs.bumpType }}" = "major" ]; then | |
let new_major=${{ steps.parsed-release.outputs.major }}+1 | |
new_release_branch="releases/$new_major.0.x" | |
elif [ "${{ github.event.inputs.bumpType }}" = "minor" ]; then | |
let new_minor=${{ steps.parsed-release.outputs.minor }}+1 | |
new_release_branch="releases/${{ steps.parsed-release.outputs.major }}.$new_minor.x" | |
else | |
echo "cannot make patch release from main branch" | |
exit 1 | |
fi | |
elif [[ "${{ github.ref }}" = refs/heads/releases/* ]]; then | |
if [ "${{ github.event.inputs.bumpType }}" != "patch" ]; then | |
echo "cannot make major/minor release from release branch" | |
exit 1 | |
fi | |
else | |
echo "can only release from main or releases/* branches" | |
exit 1 | |
fi | |
git config --global user.email "[email protected]" | |
git config --global user.name "axelar-cicd-bot" | |
git commit --allow-empty -m "${{ steps.release.outputs.new_tag }}" | |
git push | |
if [ -n "$new_release_branch" ]; then | |
git checkout -b $new_release_branch | |
git push -u origin $new_release_branch | |
fi | |
- name: Bump version and push tag | |
uses: anothrNick/[email protected] | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
DEFAULT_BUMP: ${{ github.event.inputs.bumpType }} | |
TAG_CONTEXT: branch | |
RELEASE_BRANCHES: main,releases.* | |
WITH_V: true |