Skip to content

Commit 8b5387b

Browse files
author
Matija Petrunic
committed
Update release pipeline
1 parent 4ff00f6 commit 8b5387b

File tree

1 file changed

+73
-20
lines changed

1 file changed

+73
-20
lines changed

.github/workflows/npm-publish.yml

Lines changed: 73 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,80 @@
1-
name: npm-publish
1+
name: Release
2+
23
on:
34
push:
45
branches:
5-
- master # Change this to your default branch
6+
- 'master'
7+
68
jobs:
7-
npm-publish:
8-
name: npm-publish
9+
tag:
10+
name: Check and Tag
911
runs-on: ubuntu-latest
1012
steps:
11-
- name: Checkout repository
12-
uses: actions/checkout@master
13-
- name: Set up Node.js
14-
uses: actions/setup-node@master
13+
- name: Checkout code
14+
uses: actions/checkout@v2
15+
- name: Create tag
16+
id: tag
17+
uses: butlerlogic/action-autotag@1.1.1
1518
with:
16-
node-version: 12.4.0
17-
- name: Build library
18-
run: yarn install --frozen-lockfile && yarn run build
19-
- name: Publish if version has been updated
20-
uses: pascalgn/npm-publish-action@1.2.0
21-
with: # All of theses inputs are optional
22-
tag_name: "v%s"
23-
tag_message: "v%s"
24-
commit_pattern: "^[R|r]elease v?(\\S+)"
25-
env: # More info about the environment variables in the README
26-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Leave this as is, it's automatically generated
27-
NPM_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }} # You need to set this in your repo settings
19+
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
20+
strategy: package # Optional, since "package" is the default strategy
21+
tag_prefix: "v"
22+
outputs:
23+
tag: ${{ steps.tag.outputs.tagname }}
24+
version: ${{ steps.tag.outputs.version }}
25+
26+
publish:
27+
name: Publish
28+
runs-on: ubuntu-latest
29+
needs: tag
30+
if: ${{ needs.tag.outputs.tag != ''}}
31+
steps:
32+
- name: Checkout code
33+
uses: actions/checkout@v2
34+
- name: Setup Nodejs
35+
uses: actions/setup-node@v1
36+
with:
37+
node-version: '12.x'
38+
always-auth: true
39+
registry-url: 'https://registry.npmjs.org'
40+
env:
41+
NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
42+
- name: Install dependencies
43+
run: yarn install --frozen-lockfile --non-interactive
44+
45+
- name: Build packages
46+
run: yarn run build
47+
48+
- name: Publish packages
49+
# manual switch to latest
50+
run: yarn publish --ignore-scripts --no-git-tag-version --no-commit-hooks --non-interactive --tag beta
51+
env:
52+
NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
53+
54+
- name: Get Changelog Entry
55+
id: changelog_reader
56+
uses: mindsers/changelog-reader-action@v2
57+
with:
58+
version: ${{ needs.tag.outputs.version }}
59+
path: ./CHANGELOG.md
60+
61+
- name: Create Release
62+
id: create_release
63+
uses: actions/create-release@v1
64+
env:
65+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
66+
with:
67+
tag_name: ${{ needs.tag.outputs.tag }}
68+
body: ${{ steps.changelog_reader.outputs.changes }}
69+
prerelease: true
70+
release_name: Release ${{ needs.tag.outputs.tag }}
71+
#in case of failure
72+
- name: Rollback on failure
73+
if: failure()
74+
uses: author/action-rollback@9ec72a6af74774e00343c6de3e946b0901c23013
75+
with:
76+
id: ${{ steps.create_release.outputs.id }}
77+
tag: ${{ needs.tag.outputs.tag }}
78+
delete_orphan_tag: true
79+
env:
80+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)