-
Notifications
You must be signed in to change notification settings - Fork 17
54 lines (47 loc) · 1.62 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
name: Release
on:
push:
branches:
- main
permissions:
contents: write
jobs:
release:
name: Release
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
- name: Validate Release Commit
run: |
if [[ "${{ github.event.head_commit.message }}" != *"release-spm"* ]]
then
echo "Commit message does not contain 'release-spm', skipping release."
exit 1
fi
- name: Extract release version
uses: actions/github-script@d7906e4ad0b1822421a7e6a35d5ca353c962f410 # v6.4.1
id: extract-release-version
with:
result-encoding: string
script: |
const matches = `${{ github.event.head_commit.message }}`.match(/[0-9]+\.[0-9]+\.[0-9]+/) ?? []
return matches.length > 0 ? matches[0] : ""
- name: Validate Version Format
env:
RELEASE_VERSION: ${{ steps.extract-release-version.outputs.result }}
run: |
[[ ! -z "$RELEASE_VERSION" ]] || exit 1
echo "Valid release version: $RELEASE_VERSION"
- name: Create Release Tag
uses: actions/github-script@d7906e4ad0b1822421a7e6a35d5ca353c962f410 # v6.4.1
env:
RELEASE_VERSION: ${{ steps.extract-release-version.outputs.result }}
with:
script: |
github.rest.git.createRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: `refs/tags/${process.env.RELEASE_VERSION}`,
sha: context.sha
})