-
Notifications
You must be signed in to change notification settings - Fork 1
44 lines (42 loc) · 1.44 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
name: Publish to NPM
on:
release:
tags:
- '**-[0-9].[0-9].[0-9]'
- '**-[0-9].[0-9].[0-9]-*'
types: [published]
jobs:
build-and-publish:
runs-on: ubuntu-latest
steps:
# Source checkout
- uses: actions/checkout@v2
with:
ref: ${{ github.event.release.target_commitish }}
# Setting Node environment
- name: Setting up Node environment
uses: actions/setup-node@v1
with:
node-version: 16
registry-url: https://registry.npmjs.org/
# Environment configuration
- name: Preparing environment for release
run: |
VERSION=$(echo $GITHUB_REF_NAME | sed 's/^.*[A-Za-z]-//g')
echo "VERSION=$VERSION" >> $GITHUB_ENV
echo "PACKAGE=$(echo $GITHUB_REF_NAME | sed "s/-${VERSION}//g")" >> $GITHUB_ENV
# Release process
- name: Release
run: |
npm ci
git config --global user.name "Automated NPM Release"
git config --global user.email "[email protected]"
npm version $VERSION --allow-same-version --workspace "@aligent/cdk-${{env.PACKAGE}}"
npm run build --workspace "@aligent/cdk-${{env.PACKAGE}}"
npm test --workspace "@aligent/cdk-${{env.PACKAGE}}" --if-present
npm publish --access public --workspace "@aligent/cdk-${{env.PACKAGE}}"
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- run: git push
env:
github-token: ${{ secrets.GITHUB_TOKEN }}