-
Notifications
You must be signed in to change notification settings - Fork 0
109 lines (95 loc) · 3.04 KB
/
action-deploy.yaml
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
name: Release and Publish
on:
release:
types:
- released
permissions:
contents: write
actions: write
checks: write
id-token: write
jobs:
Test:
uses: ./.github/workflows/action-test.yaml
Strip_Version:
runs-on: ubuntu-latest
outputs:
CLEAN_TAG: ${{ steps.set-output.outputs.CLEAN_TAG }}
steps:
- name: Strip "v" from Tag
id: set-output
run: echo "CLEAN_TAG=${GITHUB_EVENT_RELEASE_TAG_NAME#v}" >> $GITHUB_OUTPUT
env:
GITHUB_EVENT_RELEASE_TAG_NAME: ${{ github.event.release.tag_name }}
Publish:
runs-on: ubuntu-latest
outputs:
GIT_BRANCH_TARGET: ${{ steps.set-npm-tag.outputs.GIT_BRANCH_TARGET }}
needs: ['Test', 'Strip_Version']
env:
CLEAN_TAG: ${{ needs.Strip_Version.outputs.CLEAN_TAG }}
steps:
- name: Create Directory
run: mkdir -p ./lib
- name: Download the build artifact
uses: actions/download-artifact@v4
with:
name: cache
path: ./
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: lts/*
registry-url: 'https://registry.npmjs.org/'
- name: Update Version in Package.json
id: set-npm-tag
run: |
npm version $CLEAN_TAG --no-git-tag-version
if [[ "$CLEAN_TAG" == *"beta"* ]]; then
echo "NPM_TAG=beta" >> $GITHUB_OUTPUT
echo "GIT_BRANCH_TARGET=develop" >> $GITHUB_OUTPUT
else
echo "NPM_TAG=latest" >> $GITHUB_OUTPUT
echo "GIT_BRANCH_TARGET=main" >> $GITHUB_OUTPUT
fi
- name: Publish to npm
uses: JS-DevTools/npm-publish@v3
with:
provenance: true
token: ${{ secrets.NPM_TOKEN }}
tag: ${{ steps.set-npm-tag.outputs.NPM_TAG }}
Update_Repo:
runs-on: ubuntu-latest
needs: ['Test', 'Strip_Version', 'Publish']
permissions:
contents: write
actions: write
checks: write
env:
CLEAN_TAG: ${{ needs.Strip_Version.outputs.CLEAN_TAG }}
GIT_BRANCH_TARGET: ${{ needs.Publish.outputs.GIT_BRANCH_TARGET }}
steps:
# - uses: hmarr/debug-action@v3
- uses: actions/checkout@v4
with:
token: '${{ secrets.GITHUB_TOKEN }}'
ref: ${{ env.GIT_BRANCH_TARGET }}
sparse-checkout: |
package.json
CHANGELOG.md
sparse-checkout-cone-mode: false
- name: Update Version in Package.json
id: set-git-branch
run: npm version $CLEAN_TAG --no-git-tag-version
- name: Update Changelog
uses: stefanzweifel/changelog-updater-action@v1
with:
latest-version: ${{ github.event.release.name }}
release-notes: ${{ github.event.release.body }}
- name: Commit and Push Version Update
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: "chore(release): ${{ github.event.release.tag_name }} [skip ci]"
Document:
needs: ['Update_Repo', 'Publish']
uses: ./.github/workflows/action-docs.yaml