-
Notifications
You must be signed in to change notification settings - Fork 29
127 lines (109 loc) · 3.82 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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
name: Release
on:
workflow_dispatch:
inputs:
releaseType:
description: 'Release Type'
required: true
type: choice
default: 'patch'
options:
- patch
- minor
- major
releaseChannel:
description: 'Release Channel'
required: true
type: choice
default: stable
options:
- stable
- pre
jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Input parameters
run: echo "${{ toJSON(github.event.inputs) }}"
- name: Clone Repository
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup Git
run: |
git config --global user.name "github-actions"
git config --global user.email "[email protected]"
- name: Get Current Version Number
run: |
CURRENT_VERSION=$(npm pkg get version | cut -d'"' -f 2)
echo "CURRENT_VERSION=$CURRENT_VERSION" >> $GITHUB_ENV
echo $CURRENT_VERSION
- name: Setup Node version
uses: actions/setup-node@v3
with:
node-version: 18
registry-url: 'https://registry.npmjs.org'
cache: 'npm'
cache-dependency-path: |
package-lock.json
- name: Install dependencies
run: npm ci
- name: Bump version (Pre)
run: |
RELEASE_VERSION=$(npx semver -i prerelease --preid=pre $CURRENT_VERSION)
echo "RELEASE_VERSION=$RELEASE_VERSION" >> $GITHUB_ENV
npm version $RELEASE_VERSION --git-tag-version=false
if: ${{ github.event.inputs.releaseChannel == 'pre' }}
- name: Bump version (Stable)
run: |
RELEASE_VERSION=$(npx semver $CURRENT_VERSION -i ${{ github.event.inputs.releaseType }})
echo "RELEASE_VERSION=$RELEASE_VERSION" >> $GITHUB_ENV
npm version $RELEASE_VERSION --git-tag-version=false
if: ${{ github.event.inputs.releaseChannel == 'stable' }}
- name: Update Changelog (Stable)
run: node scripts/update-changelog.mjs
if: ${{ github.event.inputs.releaseChannel == 'stable' }}
- name: Tagging
run: |
git add .
git commit -m "$RELEASE_VERSION"
git tag -a v$RELEASE_VERSION -m "$RELEASE_VERSION"
- name: Push tag
run: |
git push
git push origin --tags
- run: |
export GIT_TAG=$(git describe --tags --abbrev=0)
echo "GIT_TAG=$GIT_TAG" >> $GITHUB_ENV
- name: Build package
run: |
npm run build
npm pack
- name: Publish to Npmjs.com (Pre)
run: npm publish --access=public --scope=@vsc-elements --tag=next vsc-elements-elements-${{ env.RELEASE_VERSION }}.tgz
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
if: ${{ github.event.inputs.releaseChannel == 'pre' }}
- name: Publish to Npmjs.com (Stable)
run: npm publish --access=public --scope=@vsc-elements vsc-elements-elements-${{ env.RELEASE_VERSION }}.tgz
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
if: ${{ github.event.inputs.releaseChannel == 'stable' }}
- name: Github Release (Pre)
uses: ncipollo/release-action@v1
if: ${{ github.event.inputs.releaseChannel == 'pre' }}
with:
artifacts: './vsc-elements-elements-*'
prerelease: true
draft: true
tag: ${{ env.GIT_TAG }}
generateReleaseNotes: true
- name: Github Release (Stable)
uses: ncipollo/release-action@v1
if: ${{ github.event.inputs.releaseChannel == 'stable' }}
with:
artifacts: './vsc-elements-elements-*'
prerelease: false
draft: true
tag: ${{ env.GIT_TAG }}
generateReleaseNotes: true