forked from ERC725Alliance/erc725.js
-
Notifications
You must be signed in to change notification settings - Fork 0
102 lines (86 loc) · 3.2 KB
/
release.yml
File metadata and controls
102 lines (86 loc) · 3.2 KB
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
# If it detects a version bump on main, it will trigger a release.
# If the workflow is started manually, it will skip the bump detection and attempt to publish.
name: Release and publish
on:
workflow_dispatch:
push:
branches:
- 'main'
jobs:
release:
name: 📦 Create GitHub release and publish to NPM
runs-on: ubuntu-latest
steps:
- name: Ensure main branch
if: github.ref != 'refs/heads/main'
run: |-
echo "Not running on main - exit"
exit 1
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: 🔍 Check if version changed
uses: EndBug/version-check@v1
if: github.event_name == 'push'
id: check
- name: 🔄 Check if should release
run: echo "SHOULD_RELEASE=${{ steps.check.outputs.changed == 'true' || github.event_name == 'workflow_dispatch' }}" >> $GITHUB_ENV
- name: ⚙️ Setup Node.js v16
uses: actions/setup-node@v2
if: env.SHOULD_RELEASE == 'true'
with:
node-version: '16.x'
registry-url: 'https://registry.npmjs.org'
scope: '@erc725'
cache: 'npm'
- name: 📝 Set Version
if: env.SHOULD_RELEASE == 'true'
run: |-
APP_VERSION="v$(node -pe "require('./package.json').version")"
echo "APP_VERSION=$APP_VERSION" >> $GITHUB_ENV
- name: 🧰 Install
if: env.SHOULD_RELEASE == 'true'
run: npm ci
- name: 🎯 Test
if: env.SHOULD_RELEASE == 'true'
run: npm test
- name: 🛠 Build
if: env.SHOULD_RELEASE == 'true'
run: npm run build
# We assume this will be always triggered by a merge from develop
# Therefore we tag the previous commit (the merge commit won't be on develop)
- name: 🏷 Create and push Git Tag
if: env.SHOULD_RELEASE == 'true'
run: |-
git config --global user.email "release@lukso.network"
git config --global user.name "LUKSO Bot"
git tag -a ${{ env.APP_VERSION }} HEAD~ -m "Release Version ${{ env.APP_VERSION }} [CI]"
git push --set-upstream origin tag ${{ env.APP_VERSION }}
# Create GitHub Release
- name: 📝 Extract release notes from CHANGELOG
if: env.SHOULD_RELEASE == 'true'
id: extract-release-notes
uses: ffurrer2/extract-release-notes@v1
with:
release_notes_file: RELEASENOTES.md
- uses: jwalton/gh-find-current-pr@v1
if: env.SHOULD_RELEASE == 'true'
id: findPR
with:
state: closed
- name: Add PR body to Release Notes
if: env.SHOULD_RELEASE == 'true'
run: |-
echo ${{ steps.findPR.outputs.body }}|cat - RELEASENOTES.md > /tmp/out && mv /tmp/out RELEASENOTES.md
- name: 🚀 Create GitHub release
uses: ncipollo/release-action@v1
if: env.SHOULD_RELEASE == 'true'
with:
bodyFile: 'RELEASENOTES.md'
token: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ env.APP_VERSION }}
- name: 📦 Publish to NPM
if: env.SHOULD_RELEASE == 'true'
run: npm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}