forked from node-modules/github-actions
-
Notifications
You must be signed in to change notification settings - Fork 0
98 lines (83 loc) · 2.62 KB
/
node-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
88
89
90
91
92
93
94
95
96
97
98
name: Node.js Release
on:
workflow_call:
secrets:
NPM_TOKEN:
description: 'npm token'
required: true
GIT_TOKEN:
description: 'github personal token'
required: true
inputs:
checkTest:
type: boolean
description: whether run test before release
default: false
dryRun:
type: boolean
description: pass dry-run to semantic-release
default: false
install:
type: string
description: 'Install dependencies script'
default: 'npm i --no-package-lock --no-fund'
action_ref:
type: string
description: 'Branch name for node-modules/github-actions, for test purpose'
default: master
jobs:
Release:
permissions:
contents: write
id-token: write
deployments: write
runs-on: ubuntu-latest
defaults:
run:
working-directory: main_repo
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
steps:
# Checkout action repository
- name: Checkout action repository
uses: actions/checkout@v4
with:
repository: node-modules/github-actions
path: action_repo
ref: ${{ inputs.action_ref }}
# Checkout project repository
- name: Checkout project repository
uses: actions/checkout@v4
with:
path: main_repo
token: ${{ secrets.GIT_TOKEN }}
# Setup Node.js environment
- name: Setup Node.js
uses: actions/setup-node@v4
# Install action dependencies
- name: Install action dependencies
run: npm i --no-package-lock --no-fund --omit=dev
working-directory: action_repo/scripts/release
# Install dependencies
- name: Install dependencies
run: ${{ inputs.install }}
# Run Test Only
- name: Run Test
run: npm test
if: inputs.checkTest
- name: Semantic Release
id: release
run: node ../action_repo/scripts/release/index.js
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
DRYRUN: ${{ inputs.dryRun }}
NPM_CONFIG_PROVENANCE: true
- name: Publish ${{ steps.release.outputs.name }}@${{ steps.release.outputs.release_version }}
if: steps.release.outputs.release_version && !inputs.dryRun
run: |
echo ${{ steps.release.outputs.name }}
echo ${{ steps.release.outputs.release_version }}
echo ${{ steps.release.outputs.registry }}
echo ${{ steps.release.outputs.cnpm_sync_url }}