-
Notifications
You must be signed in to change notification settings - Fork 2
81 lines (76 loc) · 2.79 KB
/
release-action.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
name: Release Action version
on:
workflow_dispatch:
jobs:
cancel-previous-runs:
name: Cancel previous runs
runs-on: ubuntu-latest
steps:
- name: ⏹ Cancel Previous Runs
uses: styfle/[email protected]
with:
access_token: ${{ secrets.GITHUB_TOKEN }}
create-release:
name: Create a release of the action
runs-on: ubuntu-latest
steps:
- name: 💻 Checkout
uses: actions/checkout@v3
with:
ref: master
fetch-depth: 0
- name: 🔨 Read .nvmrc
id: read_nvmrc
run: |
echo "NODE_VERSION=$(cat .nvmrc)" >> $GITHUB_OUTPUT
- name: 🔨 Setup node
uses: actions/[email protected]
with:
node-version: ${{ steps.read_nvmrc.outputs.NODE_VERSION }}
- name: 🔨 Get npm cache directory
id: npm-cache
run: |
echo "dir=$(npm config get cache)" >> $GITHUB_OUTPUT
- name: 🔨 Cache dependencies
uses: actions/[email protected]
with:
path: ${{ steps.npm-cache.outputs.dir }}
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: 🚧 Install dependencies
run: npm ci
- name: 📦 Package the binary release
run: npm run all
- name: 🏷 Create the binary release metadata
id: create-tags
run: |
# We use the e-mail mentioned here: https://github.jparrowsec.cnmunity/t/github-actions-bot-email-address/17204/6
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config user.name "github-actions"
npm run release
TAG=$(git describe --tags --abbrev=0) # Works since vX.Y.Z tags are annotated and won't pick the vX tags, which are not
echo "tag=${TAG}" >> $GITHUB_OUTPUT # saved as output of the step
- name: ⏫ Push changes to GitHub
uses: ad-m/[email protected]
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: master
tags: true
force: true
- name: 📝 Create changelog for GitHub release
run: |
# We first need to remove the header text, and then process it with rexreplace to obtain a proper release changelog
# Reference: https://github.com/conventional-changelog/standard-version/issues/568
tail -n +5 CHANGELOG.md | npx rexreplace "^.*?#+\s\[.*?\n.*?(?=\s*#+\s\[)" "_" -s -M -G -m -o > CHANGELOG-LATEST.md
- name: 🚀 Create a release in GitHub
id: create-gh-release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.create-tags.outputs.tag }}
release_name: ${{ steps.create-tags.outputs.tag }}
body_path: CHANGELOG-LATEST.md
draft: false
prerelease: false