-
Notifications
You must be signed in to change notification settings - Fork 143
55 lines (48 loc) · 1.58 KB
/
Copy pathrelease.yml
File metadata and controls
55 lines (48 loc) · 1.58 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
name: Release
on:
workflow_dispatch:
inputs:
version:
description: "Version to release (semver, no leading v — e.g. 5.0.3)"
required: true
type: string
permissions:
contents: read
jobs:
tag:
runs-on: ubuntu-latest
environment: master
steps:
- name: Validate version
env:
VERSION: ${{ inputs.version }}
run: |
if [[ ! "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.-]+)?$ ]]; then
echo "Version must be semver (e.g. 5.0.3 or 5.0.3-beta.1)"
exit 1
fi
- name: Mint App installation token
id: app-token
uses: actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1 # v3.2.0
with:
app-id: ${{ secrets.PACKAGIST_PUBLISHER_APP_ID }}
private-key: ${{ secrets.PACKAGIST_PUBLISHER_PRIVATE_KEY }}
permission-contents: write
- name: Create annotated tag on master HEAD
env:
GH_TOKEN: ${{ steps.app-token.outputs.token }}
VERSION: ${{ inputs.version }}
REPO: ${{ github.repository }}
run: |
set -euo pipefail
SHA=$(gh api "repos/$REPO/commits/master" --jq .sha)
echo "Tagging $SHA as $VERSION"
TAG_OBJ=$(gh api -X POST "repos/$REPO/git/tags" \
-f tag="$VERSION" \
-f message="Release $VERSION" \
-f object="$SHA" \
-f type=commit \
--jq .sha)
gh api -X POST "repos/$REPO/git/refs" \
-f ref="refs/tags/$VERSION" \
-f sha="$TAG_OBJ"