-
Notifications
You must be signed in to change notification settings - Fork 0
64 lines (57 loc) · 1.85 KB
/
new_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
name: New Release
env:
REGISTRY: ghcr.io
on:
release:
types: [ published ]
# Trigger only when a release with tag v*.*.* is published
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'
jobs:
update-version:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Update version in package.json
run: |
CURRENT_TAG=${GITHUB_REF#refs/tags/}
echo "Current tag: $CURRENT_TAG"
VERSION="${CURRENT_TAG#v}"
echo "Updating version to: $VERSION"
jq ".version = \"$VERSION\"" package.json > package.json.tmp
mv package.json.tmp package.json
- name: Create Pull Request
uses: peter-evans/create-pull-request@v4
with:
title: Update package.json version
branch: update-version
commit-message: Update package.json version
body: Update the version of `package.json` as part of release process
delete-branch: true
base: main
publish:
runs-on: ubuntu-latest
needs: update-version
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '16.x'
- name: Update version in package.json
run: |
CURRENT_TAG=${GITHUB_REF#refs/tags/}
echo "Current tag: $CURRENT_TAG"
VERSION="${CURRENT_TAG#v}"
echo "Updating version to: $VERSION"
jq ".version = \"$VERSION\"" package.json > package.json.tmp
mv package.json.tmp package.json
- name: Install Dependencies
run: npm install --verbose
- name: Publish Package
run: |
echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > ~/.npmrc
npm publish --access=public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}