-
Notifications
You must be signed in to change notification settings - Fork 584
88 lines (70 loc) · 3.01 KB
/
release.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
name: Release with Changelog
on:
push:
tags:
- "ios-[0-9]*.[0-9]*.[0-9]*-[0-9]*.[0-9]*.[0-9]*.[0-9]*-sultantest"
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 --depth=300 --jobs=8
echo "fetched tags!"
- name: Determine iOS and Android tags
id: determine_tags
run: |
# Get all iOS release tags and sort them
ios_tags=$(git tag --sort=-creatordate | grep "^ios.*submission$" | head -n 10)
# 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 :lock:](https://artsynet.sentry.io/releases/${{ env.last_ios_tag }}/?project=5867225)"
android_link="Monitor the Android release on Sentry [here :lock:](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 }}"