-
Notifications
You must be signed in to change notification settings - Fork 1
86 lines (76 loc) · 2.72 KB
/
release-beta.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
name: 'release beta'
on:
workflow_dispatch:
push:
branches:
- main
paths:
- 'src/**'
- 'locale/**'
- tsconfig.json
jobs:
build:
name: release beta version
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup node
uses: actions/setup-node@v3
with:
node-version: 12
registry-url: 'https://registry.npmjs.org'
scope: '@${{ github.repository_owner }}'
- uses: actions/cache@v3
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Setup package
run: |
npm install
npm run build
- name: Bump beta version
run: |
git tag > version.txt
git tag | grep -P 'v\d+\.\d+\.\d+-beta.\d+' -o | xargs git tag -d
npx --no-install standard-version --dry-run | sed -e '1!d' -e 's/.*to //g' >> version.txt
version=`sort -rV version.txt | sed -n '1p'`
npx --no-install standard-version --release-as ${version} --skip.changelog --skip.commit --skip.tag
npx --no-install standard-version --prerelease beta --skip.commit --skip.tag
sed 's/^### \[/## [/' -i CHANGELOG.md
npx --no-install prettier --write 'CHANGELOG.md' --prose-wrap never --ignore-path './gitignore'
rm version.txt
- name: Get version from package.json
uses: actions/github-script@v6
id: version
with:
result-encoding: string
script: |
const { GITHUB_WORKSPACE } = process.env;
const version = require('./package.json').version;
core.setOutput('version', version);
- name: Get Changelog Entry
id: changelog_reader
uses: mindsers/[email protected]
with:
version: ${{ steps.version.outputs.version }}
path: ./CHANGELOG.md
- name: Create release
id: create_release
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: v${{ steps.version.outputs.version }}
release_name: Release v${{ steps.version.outputs.version }}
body: ${{ steps.changelog_reader.outputs.changes }}
prerelease: ${{ steps.changelog_reader.outputs.status == 'prereleased' }}
draft: ${{ steps.changelog_reader.outputs.status == 'unreleased' }}
- name: Publish beta package to npmjs
run: npm publish --tag beta --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}