-
Notifications
You must be signed in to change notification settings - Fork 6
75 lines (69 loc) · 2.75 KB
/
run-release.yaml
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
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 }}