Release with Changelog #5
Workflow file for this run
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 with Changelog | |
on: | |
push: | |
tags: | |
- "ios-[0-9]*.[0-9]*.[0-9]*-[0-9]*.[0-9]*.[0-9]*.[0-9]*-submission" | |
permissions: | |
contents: write | |
jobs: | |
generate-release: | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: Check out repository | |
uses: actions/checkout@v4 | |
- name: Set up Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: "20" | |
cache: "yarn" | |
- name: Fetch all tags | |
run: git fetch --tags | |
- name: Determine iOS and Android tags | |
id: determine_tags | |
run: | | |
# Get all iOS release tags and sort them | |
ios_tags=$(git tag --list "ios-*-submission" | sort -V) | |
# Get the last and second-to-last iOS tags | |
last_ios_tag=$(echo "$ios_tags" | tail -n1) | |
second_last_ios_tag=$(echo "$ios_tags" | tail -n2 | head -n1) | |
# Find the corresponding Android tag for the same commit hash as the last iOS tag | |
commit_hash=$(git rev-list -n 1 "$last_ios_tag") | |
android_tag=$(git tag --contains "$commit_hash" | grep "android-.*-submission" | head -n1) | |
# Ensure tags are found | |
if [ -z "$last_ios_tag" ] || [ -z "$second_last_ios_tag" ] || [ -z "$android_tag" ]; then | |
echo "Error: Could not determine all required tags." | |
exit 1 | |
fi | |
# Export tags for later steps | |
echo "last_ios_tag=$last_ios_tag" >> $GITHUB_ENV | |
echo "second_last_ios_tag=$second_last_ios_tag" >> $GITHUB_ENV | |
echo "android_tag=$android_tag" >> $GITHUB_ENV | |
- name: Install dependencies | |
run: | | |
npm install -g yarn | |
yarn install | |
yarn global add tsx | |
- name: Generate changelog | |
id: generate_changelog | |
run: | | |
base_changelog=$(yarn generate-changelog "${{ env.second_last_ios_tag }}" "${{ env.last_ios_tag }}") | |
# Add monitoring links | |
ios_link="Monitor the iOS release on Sentry [here](https://artsynet.sentry.io/releases/${{ env.last_ios_tag }}/?project=5867225)" | |
android_link="Monitor the Android release on Sentry [here](https://artsynet.sentry.io/releases/${{ env.android_tag }}/?project=5867225)" | |
changelog="${base_changelog}\n\n$ios_link\n$android_link" | |
echo "changelog<<EOF" >> $GITHUB_ENV | |
echo "$changelog" >> $GITHUB_ENV | |
echo "EOF" >> $GITHUB_ENV | |
env: | |
CHANGELOG_GITHUB_TOKEN_KEY: ${{ secrets.CHANGELOG_GITHUB_TOKEN_KEY }} | |
- name: Create release | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
# Extract the version from the iOS tag for the title | |
version=$(echo "${{ env.last_ios_tag }}" | sed -E 's/^ios-([0-9]+\.[0-9]+\.[0-9]+)-.*/\1/') | |
gh release create "${{ env.last_ios_tag }}" \ | |
--repo "${{ github.repository }}" \ | |
--title "$version" \ | |
--notes "${{ env.changelog }}" |