Skip to content

Trigger Release

Trigger Release #81

Workflow file for this run

name: Trigger Release
on:
workflow_dispatch:
inputs:
version:
description: "Version to tag (blank will auto-generate, e.g., 'v1.10')"
required: false
jobs:
check-team:
runs-on: ubuntu-latest
steps:
- env:
GITHUB_TOKEN: ${{ secrets.ADH_BOT_ORG_TOKEN }}
run: |
access=$(gh api -H "Accept: application/vnd.github+json" -H "X-GitHub-Api-Version: 2022-11-28" /orgs/adh-partnership/teams/maintainers-frontend/memberships/${{ github.actor }})
if [ "$(echo $access | jq -r .state)" != "active" ]; then
echo "${{ github.actor }} is not a member of the maintainers-frontend team and cannot run this workflow"
exit 1
fi
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
ref: "main"
token: ${{ secrets.ADH_BOT_TOKEN }}
- name: Tag Release
id: tag
env:
GITHUB_TOKEN: ${{ secrets.ADH_BOT_TOKEN }}
run: |
git config --global user.name "adh-bot"
git config --global user.email "[email protected]"
git fetch --tags
set -ex
version=${{ github.event.inputs.version }}
if [ -z "$version" ]; then
previous_tag=$(git tag --sort=-creatordate | head -n 1)
version=$(echo $previous_tag | awk -F. -v OFS=. '{$2++;print $1,$2}')
fi
# Append epoch and build number to version
version="${version}.$(date +%s).${{ github.run_number }}"
echo "Version: $version"
echo "version=$version" >> "$GITHUB_OUTPUT"
# Tag the release
git tag "$version"
git push origin "$version"
# Increment version in .env
new_version=$(echo $version | awk -F. -v OFS=. '{$2++;print $1,$2}')
git checkout -b "bump-version-$new_version"
# Check if .version already has new_version (strip newline)
if [ "$(cat .version | tr -d '\n')" == "${new_version}.0-dev" ]; then
echo "Version already bumped to $new_version"
exit 0
fi
echo "${new_version}.0-dev" > .version
git add .version
git commit -m "Increment dev version to $new_version"
git push origin "bump-version-$new_version"
gh pr create -t "Bump version to $new_version" -b "Bump version to $new_version" -B "main" -l "dependencies" -l "auto-merge"
echo "Created PR to bump version to $new_version"
- name: Create Release
uses: ncipollo/release-action@v1
with:
tag: ${{ steps.tag.outputs.version }}
allowUpdates: true
omitBodyDuringUpdate: true
generateReleaseNotes: true
token: ${{ secrets.ADH_BOT_TOKEN }}