-
Notifications
You must be signed in to change notification settings - Fork 55
111 lines (105 loc) · 4.11 KB
/
create-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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
name: Create Release
on:
workflow_dispatch:
inputs:
crateName:
description: 'Crate to Release'
required: true
default: 'mask'
type: choice
options:
- mask
- mask-parser
releaseVersion:
description: 'Version'
required: true
changelogUpdated:
description: 'Is the CHANGELOG up to date?'
required: true
type: boolean
permissions:
contents: write
env:
VERSION: ${{ github.event.inputs.releaseVersion }}
jobs:
release-mask:
if: ${{ github.event.inputs.crateName == 'mask' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
# Must use a PAT to bypass the branch protection rule (allows pushing commits without requiring PRs)
token: ${{ secrets.GH_PAT_TO_TRIGGER_RELEASE_WORKFLOW }}
- name: Validate version number input
run: |
if [[ ! "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "ERROR: invalid version number supplied '$VERSION'"
exit 1
fi
- name: Verify CHANGELOG was updated
run: |
if [[ "${{ github.event.inputs.changelogUpdated }}" != "true" ]]; then
echo "ERROR: you must update CHANGELOG before creating a new release"
exit 1
fi
UNRELEASED_CHANGES=$(sed -n '/## UNRELEASED/,/## v/{//b;p}' CHANGELOG.md)
if [[ "$UNRELEASED_CHANGES" == "" ]]; then
echo "ERROR: CHANGELOG is missing release notes"
exit 1
fi
# Write the release notes to a temp file we'll use below
echo "$UNRELEASED_CHANGES" > ../RELEASE_NOTES.txt
- name: Set up git user
run: |
git config user.name github-actions
git config user.email [email protected]
- name: Commit version bumps
run: |
# Bump the version in the changelog
sed -i "s/## UNRELEASED/## UNRELEASED\\n\\n\\n## v$VERSION ($(date '+%Y-%m-%d'))/" "CHANGELOG.md"
# Bump the crate version
sed -i "3s/.*/version = \"$VERSION\"/" "mask/Cargo.toml"
# Let cargo bump the version in the lockfile
cargo check
git add -A && git commit -m "Publish mask v$VERSION"
git push
- name: Create a new Release
env:
# Must use a PAT to ensure the Release workflow is triggered
# https://docs.github.com/en/actions/using-workflows/triggering-a-workflow#triggering-a-workflow-from-a-workflow
GH_TOKEN: ${{ secrets.GH_PAT_TO_TRIGGER_RELEASE_WORKFLOW }}
run: |
gh release create "mask/$VERSION" --title "mask v$VERSION" --notes-file ../RELEASE_NOTES.txt
release-mask-parser:
if: ${{ github.event.inputs.crateName == 'mask-parser' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
# Must use a PAT to bypass the branch protection rule (allows pushing commits without requiring PRs)
token: ${{ secrets.GH_PAT_TO_TRIGGER_RELEASE_WORKFLOW }}
- name: Validate version number input
run: |
if [[ ! "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "ERROR: invalid version number supplied '$VERSION'"
exit 1
fi
- name: Set up git user
run: |
git config user.name github-actions
git config user.email [email protected]
- name: Commit version bumps
run: |
# Bump the crate version
sed -i "3s/.*/version = \"$VERSION\"/" "mask-parser/Cargo.toml"
# Let cargo bump the version in the lockfile
cargo check
git add -A && git commit -m "Publish mask-parser v$VERSION"
git push
- name: Create a new Release
env:
# Must use a PAT to ensure the Release workflow is triggered
# https://docs.github.com/en/actions/using-workflows/triggering-a-workflow#triggering-a-workflow-from-a-workflow
GH_TOKEN: ${{ secrets.GH_PAT_TO_TRIGGER_RELEASE_WORKFLOW }}
run: |
gh release create "mask-parser/$VERSION" --title "mask-parser v$VERSION"