generated from actions/typescript-action
-
Notifications
You must be signed in to change notification settings - Fork 1
133 lines (109 loc) · 4.02 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
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
name: release
concurrency:
group: release
cancel-in-progress: true
on:
push:
branches:
- main
workflow_dispatch:
permissions:
contents: read
jobs:
validate-release-trigger:
runs-on: ubuntu-latest
steps:
- name: check if release should be skipped
id: lastcommit
shell: bash
# As described in the docs the skip-checks should prevent this push-triggered action from execution.
# But the action still triggers - not sure why this is the case.
# see: https://docs.github.com/en/actions/managing-workflow-runs/skipping-workflow-runs
run: |
if [[ ${{ toJSON(github.event.head_commit.message) }} == *"skip-checks: true"* ]]; then
echo "'skip-checks: true' found"
echo "::set-output name=skipchecks::true"
else
echo "'skip-checks: true' NOT found"
echo "::set-output name=skipchecks::false"
fi
outputs:
skipchecks: ${{ steps.lastcommit.outputs.skipchecks }}
release-drafter:
runs-on: ubuntu-latest
needs: validate-release-trigger
permissions:
contents: write # for release-drafter/release-drafter to create a github release
pull-requests: write # for release-drafter/release-drafter to add label to PR
if: ${{ needs.validate-release-trigger.outputs.skipchecks == 'false' }}
steps:
# Drafts your next Release notes as Pull Requests are merged into "main"
- uses: release-drafter/release-drafter@v6
id: releasedrafter
with:
config-name: release-drafter.yaml
publish: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
outputs:
tag: ${{ steps.releasedrafter.outputs.tag_name }}
release:
runs-on: ubuntu-latest
needs: release-drafter
steps:
- name: checkout repository
uses: actions/checkout@v4
with:
# Using PAT because if the action will be triggered automatically by dependabot the GITHUB_TOKEN has no write permission
# see: https://github.blog/changelog/2021-02-19-github-actions-workflows-triggered-by-dependabot-prs-will-run-with-read-only-permissions/
token: ${{ secrets.PAT }}
- name: install node 16.x
uses: actions/setup-node@v4
with:
node-version: 16.x
- name: download dependencies
shell: bash
run: npm install
- name: build binaries
shell: bash
run: npm run build
- name: package binaries
shell: bash
run: npm run package
- name: bump version (npm)
shell: bash
run: npm version --no-git-tag-version --new-version ${{ needs.release-drafter.outputs.tag }}
- name: bump version (README)
shell: bash
run: sed -i -E "s/@(v[0-9]*\.[0-9]*\.[0-9]*)/@${{ needs.release-drafter.outputs.tag }}/g" README.md
- name: commit version bump
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: |
chore(release): update version to ${{ needs.release-drafter.outputs.tag }}
skip-checks: true
branch: main
file_pattern: package.json README.md
- name: configure git
shell: bash
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
- name: commit binaries
shell: bash
run: |
git checkout -b release/${{ needs.release-drafter.outputs.tag }}
git add --force dist/
git commit \
-m "chore(release): add binaries ${{ needs.release-drafter.outputs.tag }}" \
-m "skip-checks: true"
- name: move release tag
shell: bash
run: |
git tag --force ${{ needs.release-drafter.outputs.tag }} HEAD
git push --force origin ${{ needs.release-drafter.outputs.tag }}
- name: update latest tag
shell: bash
run: |
git tag --force latest HEAD
git push --force origin latest