-
Notifications
You must be signed in to change notification settings - Fork 3
95 lines (93 loc) · 3.74 KB
/
push-tagged-release.yml
File metadata and controls
95 lines (93 loc) · 3.74 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
name: "⬆️ Push: package & tagged release"
on:
workflow_call:
inputs:
sha:
required: true
type: string
ref:
required: true
type: string
sectionChangelog:
type: string
onlyNpmPush:
type: boolean
default: false
secrets:
chromaticToken:
required: true
npmjsToken:
required: true
jobs:
push-tagged-release:
runs-on: "ubuntu-latest"
steps:
- name: Check input vars
run: |
echo ${{ inputs.ref }}
echo ${{ inputs.sha }}
echo ${{ inputs.sectionChangelog }}
echo ${{ inputs.onlyNpmPush }}
- uses: actions/checkout@main
with:
fetch-depth: 0
ref: ${{ inputs.ref }}
- uses: actions/setup-node@main
with:
node-version: "lts/krypton"
registry-url: "https://registry.npmjs.org"
- name: Set name vars
id: info-vars
run: |
echo "sha=${GITHUB_SHA}" >> $GITHUB_OUTPUT
echo "tag=${{ inputs.ref }}" >> $GITHUB_OUTPUT
echo "version=$(echo ${{ inputs.ref }} | cut -c2-)" >> $GITHUB_OUTPUT
- name: Get changelog entry
# only use for final releases -- for other pre-releases the changelog is visible in the PR
if: inputs.onlyNpmPush != true
id: info-changelog
uses: mindsers/changelog-reader-action@v2
with:
version: ${{ inputs.sectionChangelog }}
- name: Install dependencies
run: yarn install
- name: Create dist JS
run: yarn build:all
- name: Create jest results
# only use for final releases because it is necessary only in addition to storybook
if: ${{ inputs.onlyNpmPush != true && inputs.sectionChangelog != 'Unreleased' }}
run: yarn test:generate-output
- name: Publish to Chromatic
# publish storybook only for final releases -- for other pre-releases the storybook has a link in PR
if: ${{ inputs.onlyNpmPush != true && inputs.sectionChangelog != 'Unreleased' }}
id: chromatic-upload
uses: chromaui/action@v11
with:
token: ${{ secrets.GITHUB_TOKEN }}
projectToken: ${{ secrets.chromaticToken }}
exitZeroOnChanges: true
- name: Publish npm package
run: yarn publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.npmjsToken }}
- name: Prepare release info
# only use for final releases and RCs -- other pre-releases do not need an official announcement
if: inputs.onlyNpmPush != true
run: |
touch ./releasecontent.md
CHANGELOG=$(cat <<"EOL"
${{ steps.info-changelog.outputs.changes }}
EOL
)
echo "* NPM package: https://www.npmjs.com/package/@eccenca/gui-elements/v/${{ steps.info-vars.outputs.version }}" >> ./releasecontent.md
$( if [[ ! "${{ inputs.sectionChangelog }}" =~ ^(Unreleased)$ ]]; then echo "* Storybook: ${{ steps.chromatic-upload.outputs.storybookUrl }}" >> ./releasecontent.md; fi )
$( if [[ ! "${{ inputs.sectionChangelog }}" =~ ^(Unreleased)$ ]]; then echo "${CHANGELOG}" >> ./releasecontent.md; else echo "* Changelog: https://github.com/eccenca/gui-elements/blob/${{ inputs.ref }}/CHANGELOG.md#unreleased" >> ./releasecontent.md; fi )
- name: Publish release
# only use for final releases and RCs -- other pre-releases do not need an official announcement
if: inputs.onlyNpmPush != true
uses: ncipollo/release-action@v1
with:
tag: ${{ steps.info-vars.outputs.tag }}
bodyFile: ./releasecontent.md
prerelease: ${{ steps.info-changelog.outputs.status == 'unreleased' }}
token: ${{ secrets.GITHUB_TOKEN }}