-
Notifications
You must be signed in to change notification settings - Fork 0
68 lines (61 loc) · 2.04 KB
/
Copy pathrelease.yml
File metadata and controls
68 lines (61 loc) · 2.04 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
name: Release
on:
workflow_run:
workflows: [Lint]
types: [completed]
branches: [main]
permissions:
contents: write
jobs:
release:
if: ${{ github.event.workflow_run.conclusion == 'success' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.workflow_run.head_sha }}
fetch-depth: 0
- name: Read version from package.json
id: version
shell: bash
run: |
v=$(node -p "require('./package.json').version")
if [[ -z "$v" || "$v" == "undefined" ]]; then
echo "::error::Could not read .version from package.json"; exit 1
fi
echo "value=$v" >> "$GITHUB_OUTPUT"
echo "tag=v$v" >> "$GITHUB_OUTPUT"
- name: Check whether the tag already exists
id: check
shell: bash
run: |
tag="${{ steps.version.outputs.tag }}"
if git rev-parse --verify "refs/tags/$tag" >/dev/null 2>&1; then
echo "::notice::Tag $tag already exists; skipping release."
echo "exists=true" >> "$GITHUB_OUTPUT"
else
echo "exists=false" >> "$GITHUB_OUTPUT"
fi
- name: Create annotated tag
if: steps.check.outputs.exists == 'false'
shell: bash
env:
GIT_AUTHOR_NAME: github-actions[bot]
GIT_AUTHOR_EMAIL: 41898282+github-actions[bot]@users.noreply.github.com
GIT_COMMITTER_NAME: github-actions[bot]
GIT_COMMITTER_EMAIL: 41898282+github-actions[bot]@users.noreply.github.com
run: |
tag="${{ steps.version.outputs.tag }}"
git tag -a "$tag" -m "Release $tag"
git push origin "$tag"
- name: Create GitHub Release
if: steps.check.outputs.exists == 'false'
env:
GH_TOKEN: ${{ github.token }}
shell: bash
run: |
tag="${{ steps.version.outputs.tag }}"
gh release create "$tag" \
--title "$tag" \
--generate-notes \
--verify-tag