-
Notifications
You must be signed in to change notification settings - Fork 1
72 lines (70 loc) · 2.1 KB
/
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
name: Build release
on:
workflow_dispatch:
inputs:
version:
description: 'Version of release'
type: string
required: true
update-major-tag:
description: 'Update major release tag to current release'
type: boolean
required: true
default: false
jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
registry-url: 'https://npm.pkg.github.com'
- name: Setup project
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
npm ci
- name: Test and build code
run: |
npm run lint
npm run test
npm run build
- name: Build release
run: |
npm version ${{ inputs.version }} --no-commit-hooks --no-git-tag-version
npm run release
- uses: stefanzweifel/git-auto-commit-action@v5
id: commit-step
with:
commit_message: Release version v${{ inputs.version }}
tagging_message: v${{ inputs.version }}
- if: inputs.update-major-tag
name: Update major version tag
uses: actions/github-script@v7
env:
VERSION: ${{ inputs.version }}
SHA: ${{ steps.commit-step.outputs.commit_hash }}
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
const { VERSION, SHA } = process.env
const tag = "v" + VERSION.split(".")[0]
if (tag === "v") {
return
}
try {
await github.git.deleteRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: "tags/" + tag
})
} catch (e) {
console.log("The tag " + tag + " doesn't exist yet.")
}
await github.git.createRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: "refs/tags/" + tag,
sha: SHA
})