-
Notifications
You must be signed in to change notification settings - Fork 0
85 lines (77 loc) · 3.17 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
# This is a basic workflow to help you get started with Actions
name: Release
# Controls when the workflow will run
on:
push:
branches:
- main
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
runs-on: ubuntu-latest
# Skip release commits - prevents recursive builds
if: "!contains(github.event.head_commit.message, 'chore(release)')"
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: '14'
cache: 'npm'
- run: npm install
- run: npm test
- run: npm run build
- run: npm run lint
publish:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: '14'
cache: 'npm'
registry-url: 'https://registry.npmjs.org'
- run: npm install
- run: npm run build
- run: git config --global user.email "[email protected]"
- run: git config --global user.name "GitHub Actions"
- run: git rev-parse --abbrev-ref HEAD
- name: Release new version to NPM & GitHub, generate changelog
env:
GH_TOKEN: ${{ secrets.GH_PUSH_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
NPM_CONFIG_REGISTRY: https://registry.npmjs.org:8443/ # https://github.com/semantic-release/npm/issues/277#issuecomment-723431906
run: npm run release
- name: get-npm-version
id: package-version
uses: martinbeentjes/npm-get-version-action@master
- run: git checkout -b release/${{ steps.package-version.outputs.current-version }}
- uses: actions/setup-node@v2
name: Publish new version to GitHub packages
with:
registry-url: 'https://npm.pkg.github.com'
# Defaults to the user or organization that owns the workflow file
scope: '@${OWNER}'
- run: git add CHANGELOG.md package.json package-lock.json
- run: 'git commit -m "chore(release): ${{ steps.package-version.outputs.current-version }}" -m "[skip ci]"'
- name: Push changes
# Publish to GitHub Packages
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GH_PUSH_TOKEN }}
branch: 'release/${{ steps.package-version.outputs.current-version }}'
- run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: pull-request
uses: repo-sync/pull-request@v2
with:
source_branch: 'release/${{ steps.package-version.outputs.current-version }}'
destination_branch: main
pr_title: 'chore(release): ${{ steps.package-version.outputs.current-version }}'
pr_body: 'Auto-compile changelog, increment package, then auto-merge changes made for v${{ steps.package-version.outputs.current-version }} into main. [skip ci]'
pr_label: 'pr/auto-approve'
github_token: ${{ secrets.GH_PUSH_TOKEN }}