-
Notifications
You must be signed in to change notification settings - Fork 3
134 lines (112 loc) · 3.91 KB
/
release.yml
File metadata and controls
134 lines (112 loc) · 3.91 KB
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
name: Release
on:
workflow_dispatch:
inputs:
dry-run:
description: 'Run in dry-run mode (no actual publishing)'
required: false
default: false
type: boolean
npm-tag:
description: 'NPM tag for publishing'
required: false
default: 'latest'
type: choice
options:
- latest
- alpha
- beta
- canary
env:
DEBUG: napi:*
jobs:
build:
name: Build
uses: rstackjs/rspack-toolchain/.github/workflows/build.yml@v1
with:
napi-build-command: pnpm build --release
test:
name: Test
uses: ./.github/workflows/test.yml
needs: build
release:
runs-on: ubuntu-latest
environment: npm
name: Release
permissions:
contents: write
id-token: write
needs: [build, test]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Display release mode
run: |
echo "🚀 Release Configuration:"
echo " - Dry-run mode: ${{ inputs.dry-run }}"
echo " - NPM tag: ${{ inputs.npm-tag || 'latest' }}"
if [ "${{ inputs.dry-run }}" == "true" ]; then
echo " - ⚠️ This is a DRY RUN - no packages will be published"
else
echo " - 📦 This will PUBLISH packages to npm"
fi
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '22'
- name: Enable corepack
run: corepack enable
- name: Setup pnpm
run: corepack prepare
- name: Cache pnpm dependencies
uses: actions/cache@v3
with:
path: ~/.pnpm-store
key: ${{ runner.os }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-
- name: Install dependencies
run: pnpm install
# Fix: Resolve disk space error "ENOSPC: no space left on device" on GitHub Actions runners
- name: Free disk cache
if: ${{ runner.environment == 'github-hosted' && inputs.target == 'x86_64-unknown-linux-gnu' }}
uses: xc2/free-disk-space@fbe203b3788f2bebe2c835a15925da303eaa5efe # v1.0.0
with:
tool-cache: false
- name: Get NAPI info
id: napi-info
uses: rstackjs/rspack-toolchain/get-napi-info@a0ff0d85e7dd792d5ed23c4d55f369e4b87aae87
- name: Download rspack binding
uses: rstackjs/rspack-toolchain/download-rspack-binding@a0ff0d85e7dd792d5ed23c4d55f369e4b87aae87
with:
path: ${{ steps.napi-info.outputs.binding-directory }}/artifacts
- name: List artifacts
run: ls -R artifacts
working-directory: ${{ steps.napi-info.outputs.binding-directory }}
- name: Create npm dirs
run: pnpm napi create-npm-dirs
working-directory: ${{ steps.napi-info.outputs.binding-directory }}
- name: Move artifacts
run: pnpm napi artifacts
working-directory: ${{ steps.napi-info.outputs.binding-directory }}
- name: List npm dirs
run: ls -R npm
working-directory: ${{ steps.napi-info.outputs.binding-directory }}
- name: Create npm token
run: |
echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Release npm binding packages
run: |
npm config set access public
npm config set provenance true
pnpm napi pre-publish --no-gh-release -t npm ${{ inputs.dry-run && '--dry-run' || '' }}
working-directory: ${{ steps.napi-info.outputs.binding-directory }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Release npm packages
run: |
pnpm publish -r --tag ${{ inputs.npm-tag }} --no-git-checks --provenance --access public ${{ inputs.dry-run && '--dry-run' || '' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}