forked from withastro/compiler
-
Notifications
You must be signed in to change notification settings - Fork 2
105 lines (91 loc) · 3.21 KB
/
release.yml
File metadata and controls
105 lines (91 loc) · 3.21 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
name: Release
on:
workflow_run:
workflows: [CI]
types: [completed]
branches: [main, feat/rust]
permissions:
contents: write
pull-requests: write
id-token: write
jobs:
release:
name: Release
runs-on: ubuntu-latest
if: github.event.workflow_run.conclusion == 'success'
env:
APP_NAME: astro
steps:
- uses: actions/checkout@v6
- name: Setup pnpm
uses: pnpm/action-setup@v4
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: latest
cache: pnpm
registry-url: https://registry.npmjs.org/
- name: Install dependencies
run: pnpm install
- name: Download artifacts from CI
uses: actions/download-artifact@v7
with:
path: artifacts
run-id: ${{ github.event.workflow_run.id }}
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Create npm dirs
run: pnpm napi create-npm-dirs
working-directory: crates/astro_napi
- name: Move artifacts
run: pnpm artifacts
working-directory: crates/astro_napi
- name: List packages
run: ls -R ./npm
shell: bash
working-directory: crates/astro_napi
- name: Build @astrojs/compiler
run: pnpm run build:compiler
# Check if this is a version PR merge by looking at the commit message.
# The changesets action creates PRs titled "Version Packages", so the
# merge commit will contain that string.
- name: Check if version PR merge
id: check
run: |
COMMIT_MSG=$(git log -1 --pretty=%s)
echo "commit_message=$COMMIT_MSG"
if echo "$COMMIT_MSG" | grep -q "Version Packages"; then
echo "is_release=true" >> $GITHUB_OUTPUT
else
echo "is_release=false" >> $GITHUB_OUTPUT
fi
# NAPI platform packages (e.g. @astrojs/compiler-binding-darwin-arm64)
# live under crates/astro_napi/npm/ and are NOT pnpm workspace packages.
# They must be published before the main @astrojs/compiler-binding
# package, since it lists them as optionalDependencies.
# We use `napi version` to stamp the current version into all platform
# package.json files before publishing them.
- name: Publish NAPI platform packages
if: steps.check.outputs.is_release == 'true'
run: |
echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc
npm config set provenance true
pnpm napi version
for dir in ./npm/*/; do
if [ -f "$dir/package.json" ]; then
echo "Publishing $(basename "$dir")..."
npm publish "$dir" --access public --provenance || echo "Skipped (may already exist)"
fi
done
working-directory: crates/astro_napi
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Create Release PR or Publish
id: changesets
uses: changesets/action@v1
with:
version: pnpm changeset version
publish: pnpm run release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
NPM_CONFIG_PROVENANCE: true