-
Notifications
You must be signed in to change notification settings - Fork 0
102 lines (87 loc) · 3.47 KB
/
publish.yaml
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
name: deployment
on:
push:
tags:
- 'v*.*.*'
# Pre-requirements: Just need to have a configured on the repo a secret NPM_TOKEN.
jobs:
releaseJob:
name: Update version & deploy
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v2
# ref: https://stackoverflow.com/questions/58177786/get-the-current-pushed-tag-in-github-actions
- name: Set version env
run: |
echo "RELEASE_VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_ENV
echo "TAG_VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
# ref: https://stackoverflow.com/questions/65606498/how-to-access-github-tag-message-in-github-actions
- name: Get and set tag message
run: |
git fetch --depth=1 origin +refs/tags/*:refs/tags/*
git tag -l --format='%(contents:subject)' ${GITHUB_REF#refs/*/}
echo "TAG_MESSAGE=$(git tag -l --format='%(contents:subject)' ${GITHUB_REF#refs/*/})" >> $GITHUB_ENV
- name: Test env
run: |
echo $RELEASE_VERSION
echo ${{ env.RELEASE_VERSION }}
echo $TAG_VERSION
echo ${{ env.TAG_VERSION }}
echo ${{ env.TAG_MESSAGE }}
- name: Set up Node.js
uses: actions/setup-node@v1
with:
node-version: 14.x
- name: Install dependencies
run: npm ci
# ref: https://github.community/t/auto-update-package-json-on-publishing/16894
- name: Update package version
run: |
npm --no-git-tag-version version ${{ env.RELEASE_VERSION }}
- name: Create type docs
run: |
./createTypedocs.sh
# ref: https://github.com/marketplace/actions/npm-publish
- name: NPM package publish
uses: JS-DevTools/npm-publish@v1
with:
token: ${{ secrets.NPM_TOKEN }}
access: public
registry: https://registry.npmjs.org/
- name: Github package publish
uses: JS-DevTools/npm-publish@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
access: public
registry: https://npm.pkg.github.com
# ref: https://github.com/marketplace/actions/delete-tag-and-release
- name: Delete the v tag
uses: dev-drprasad/[email protected]
with:
delete_release: true # default: false
tag_name: ${{ env.TAG_VERSION }} # tag name to delete
# repo: <owner>/<repoName> # target repo (optional). defaults to repo running this action
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# ref: https://github.com/marketplace/actions/add-commit
- name: Commit changes
uses: EndBug/add-and-commit@v7
with:
author_name: UnumID Admin
author_email: [email protected]
message: '[Release ${{ env.RELEASE_VERSION }}] ${{ env.TAG_MESSAGE }}'
add: '["package.json", "docs/", "build/"]'
branch: master
# ref: https://github.com/marketplace/actions/gh-release?version=v0.1.14
- name: Create Release
uses: softprops/[email protected]
if: startsWith(github.ref, 'refs/tags/')
with:
token: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
tag_name: ${{ env.RELEASE_VERSION }}
name: ${{ env.RELEASE_VERSION }}
generate_release_notes: true
draft: false
prerelease: false
target_commitish: master