-
Notifications
You must be signed in to change notification settings - Fork 0
148 lines (124 loc) · 3.74 KB
/
main.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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
name: main
on:
push:
branches:
- main
schedule:
- cron: "30 0/3 * * *"
# Manual dispatch, only for testing purposes. See
# https://docs.github.com/en/actions/managing-workflow-runs/manually-running-a-workflow
workflow_dispatch:
jobs:
# Check and update
check_and_update:
runs-on: ubuntu-latest
outputs:
new_version: ${{ steps.update.outputs.new_version }}
steps:
- uses: actions/checkout@v4
with:
ssh-key: "${{secrets.COMMIT_KEY}}"
# Setup Node.js
- name: Node.js
uses: actions/setup-node@v4
with:
node-version: lts/-1
# Install dependencies
- run: npm ci --verbose
# Config git user name and email
- name: Config git user name and email
run: |
git config user.name github-actions
git config user.email [email protected]
# Update tests
- name: Update tests
id: update
run: |
echo "old version: `node -p \"require('./package.json').version\"`"
new_version=`scripts/update.js`
echo "new version: ${new_version}"
echo "new_version=${new_version}" >> "$GITHUB_OUTPUT"
# Update dependencies
- name: Update dependencies
if : ${{ steps.update.outputs.new_version != '' }}
run: |
npx npm-check-updates --target semver --upgrade
npm install --verbose
# # Ensure extracted tests are working
# - name: Run tests
# if : ${{ steps.update.outputs.new_version != '' }}
# run: npm test
# Commit and push changes
- name: Commit and push changes
if : ${{ steps.update.outputs.new_version != '' }}
run: npm run release
#
# Publish to registries and GitHub release
#
# GitHub Package Registry
publish-gpr:
if : ${{ needs.check_and_update.outputs.new_version != '' }}
needs: check_and_update
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
packages: write
steps:
- uses: actions/checkout@v4
with:
ref: ${{ needs.check_and_update.outputs.new_version }}
- uses: actions/setup-node@v4
with:
node-version: lts/-2
registry-url: https://npm.pkg.github.com/
# Publish
- run: npm ci --verbose
- run: npm publish --provenance
env:
NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}
# NPM registry
publish-npm-registry:
if : ${{ needs.check_and_update.outputs.new_version != '' }}
needs: check_and_update
runs-on: ubuntu-latest
permissions:
id-token: write
steps:
- uses: actions/checkout@v4
with:
ref: ${{ needs.check_and_update.outputs.new_version }}
- uses: actions/setup-node@v4
with:
node-version: lts/-2
registry-url: https://registry.npmjs.org/
# Publish
- run: npm ci --verbose
- run: npm publish --provenance
env:
NODE_AUTH_TOKEN: ${{secrets.npm_token}}
# GitHub release
upload-to-github-release:
if : ${{ needs.check_and_update.outputs.new_version != '' }}
needs: check_and_update
permissions:
contents: write
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ needs.check_and_update.outputs.new_version }}
- uses: actions/setup-node@v4
with:
node-version: lts/-2
# Create package
- run: npm ci --verbose
- run: npm pack
# Create release
- name: Create release
uses: softprops/action-gh-release@v1
with:
files: '*.tgz'
generate_release_notes: true
tag_name: ${{ needs.check_and_update.outputs.new_version }}
# --verify-tag