-
Notifications
You must be signed in to change notification settings - Fork 23
84 lines (72 loc) · 2.72 KB
/
Copy pathrelease.yml
File metadata and controls
84 lines (72 loc) · 2.72 KB
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
name: Create Release
on: # zizmor: ignore[concurrency-limits]
workflow_dispatch:
inputs:
version:
description: 'Release version (e.g. 3.7.0)'
required: true
type: string
permissions: {}
jobs:
release:
name: Create Release
runs-on: ubuntu-latest
environment: Releases
permissions: {} # all writes go through the App token; GITHUB_TOKEN needs no scopes
steps:
- name: Resolve and validate version
env:
INPUT_VERSION: ${{ inputs.version }}
BRANCH: ${{ github.ref_name }}
run: |
version="${INPUT_VERSION#v}"
if [[ ! "$version" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.]+)?$ ]]; then
echo "::error::Version must look like 3.7.0 (got: $INPUT_VERSION)"
exit 1
fi
if [[ "$BRANCH" =~ ^[0-9]+\.x$ ]] && [ "${version%%.*}" != "${BRANCH%%.*}" ]; then
echo "::error::Version $version does not belong on the $BRANCH branch"
exit 1
fi
echo "TAG=$version" >> "$GITHUB_ENV"
- name: Get release bot token
id: app-token
uses: actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1 # v3.2.0
with:
client-id: ${{ secrets.RELEASE_APP_CLIENT_ID }}
private-key: ${{ secrets.RELEASE_APP_PRIVATE_KEY }}
permission-contents: write
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
token: ${{ steps.app-token.outputs.token }}
persist-credentials: true # zizmor: ignore[artipacked] App token is needed to push the tag
- name: Assert tag does not already exist
run: |
existing="$(git ls-remote --tags origin "$TAG")"
[ -z "$existing" ] || { echo "::error::Tag $TAG already exists on remote. Aborting."; exit 1; }
- name: Tag and push
run: |
git tag "$TAG"
git push origin "$TAG"
- name: Get Changelog
id: changelog
uses: statamic/changelog-action@5d112d0d790cdeeb5adca3e584e37edc474ab51b # v1.0.2
with:
version: ${{ env.TAG }}
- name: Create release
env:
GH_TOKEN: ${{ steps.app-token.outputs.token }}
RELEASE_NOTES: ${{ steps.changelog.outputs.text }}
IS_DEFAULT_BRANCH: ${{ github.ref_name == github.event.repository.default_branch }}
run: |
latest="$IS_DEFAULT_BRANCH"
prerelease=false
case "$TAG" in
*-*) prerelease=true; latest=false ;;
esac
gh release create "$TAG" \
--title "$TAG" \
--notes "$RELEASE_NOTES" \
--latest="$latest" \
--prerelease="$prerelease"