-
-
Notifications
You must be signed in to change notification settings - Fork 13
87 lines (69 loc) · 2.16 KB
/
publish-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
name: Publish release
on:
pull_request:
types:
- closed
branches:
- main
permissions:
contents: write
id-token: write
jobs:
create-tag:
name: Create tag
runs-on: ubuntu-latest
if: github.event.pull_request.merged == true && contains(github.event.pull_request.labels.*.name, 'new-release')
outputs:
tag-name: ${{ steps.get-tag-name.outputs.tag-name }}
steps:
- name: Checkout branch
uses: actions/checkout@v4
- name: Get tag name
id: get-tag-name
run: |
branch_name="${{ github.event.pull_request.head.ref }}"
tag_name=$(echo $branch_name | sed 's/version\///')
echo "tag-name=$tag_name" >> $GITHUB_OUTPUT
- name: Create tag
run: |
git tag "${{ env.TAG_NAME }}"
env:
TAG_NAME: ${{ steps.get-tag-name.outputs.tag-name }}
- name: Push tag to origin
run: git push origin "${{ env.TAG_NAME }}"
env:
TAG_NAME: ${{ steps.get-tag-name.outputs.tag-name }}
create-release:
name: Create release
needs: [create-tag]
runs-on: ubuntu-latest
if: needs.create-tag.outputs.tag-name != ''
permissions:
contents: write
steps:
- name: Create release
uses: ncipollo/release-action@v1
with:
tag: "${{ needs.create-tag.outputs.tag-name }}"
prerelease: ${{ contains(needs.create-tag.outputs.tag-name, '-') }}
generateReleaseNotes: true
allowUpdates: true
publish-package:
name: Publish package
runs-on: ubuntu-latest
needs: [create-tag, create-release]
steps:
- name: Checkout branch
uses: actions/checkout@v4
- name: Setup node
uses: actions/setup-node@v4
with:
registry-url: https://registry.npmjs.org/
- name: Get version
run: |
echo "NPM_VERSION=${{ needs.create-tag.outputs.tag-name }}" >> $GITHUB_ENV
- name: Publish package
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: |
npm publish --access public --provenance --tag "$(if [[ $NPM_VERSION == *-* ]]; then echo beta; else echo latest; fi)"