Repository navigation
166 lines (142 loc) · 5.67 KB
/
Copy pathrelease.yml
File metadata and controls
166 lines (142 loc) · 5.67 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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
name: Release
on:
workflow_dispatch:
inputs:
version:
description: >-
Release spec, bumped from the version every package.json shares.
`rc` (the default) publishes the next rc, e.g. `1.0.0-rc.13` to
`1.0.0-rc.14`; `rc.N` publishes that candidate. `beta[.N]` and
`alpha[.N]` select those prerelease channels. `patch|minor|major`
bump per semver, and `x.y.z[-rc.N]` publishes exactly that version.
Anything else publishes `0.0.0-<name>` without committing it.
required: false
type: string
default: "rc"
concurrency:
group: release-${{ github.ref }}
cancel-in-progress: false
permissions:
contents: write
id-token: write
env:
ALCHEMY_REPO: alchemy-run/distilled
jobs:
# The nightly Compatibility tests (compat.yml): the effect peer range, Bun
# and workerd. A failure stops the release before anything is committed.
compat:
name: Compatibility tests
permissions:
contents: read
uses: ./.github/workflows/compat-tests.yml
build:
name: Build and pack
needs: compat
runs-on: blacksmith-8vcpu-ubuntu-2404
outputs:
sha: ${{ steps.commit.outputs.sha }}
version: ${{ steps.release.outputs.version }}
channel: ${{ steps.release.outputs.channel }}
dist-tag: ${{ steps.release.outputs.dist-tag }}
steps:
- name: Generate bot token
id: bot-token
uses: actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1 # v3.2.0
with:
app-id: ${{ secrets.ALCHEMY_VERSION_BOT_ID }}
private-key: ${{ secrets.ALCHEMY_VERSION_BOT_PRIVATE_KEY }}
- name: Checkout repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0
token: ${{ steps.bot-token.outputs.token }}
- name: Setup pnpm, Node.js and install dependencies
uses: pnpm/setup@703c52620218391530e48b9e8870d5c0082e1b9b # v2.1.0
with:
cache: true
install: true
require-lockfile: true
- id: release
name: Prepare release
run: |
set -euo pipefail
node scripts/release/prepare.ts '${{ inputs.version }}' | tee -a "$GITHUB_OUTPUT"
- name: Typecheck and build all packages
run: pnpm typecheck:ci
# The chunked lib/ that preview packages ship (`pnpm build`), with
# the opt-in `distilled-lazy` stubs in lib/services.lazy that the
# packages' `exports` name.
- name: Bundle compiled JavaScript
run: node scripts/bundle-lib.ts
# Doc comments stay in .d.ts; shipping them in .js costs heap in every
# process that imports an SDK (V8 keeps module source text).
- name: Strip doc comments from compiled JavaScript
run: node scripts/strip-lib-docs.ts
- name: Pack release artifacts
run: |
set -euo pipefail
mkdir release-packages
while IFS= read -r dir; do
pnpm --dir "$dir" pack --pack-destination "$GITHUB_WORKSPACE/release-packages"
done < <(jq -r '.[].dir' release-packages.json)
# Installs every tarball into a scratch project and imports each entry
# of each package's `exports`, before anything is committed or published.
- name: Install and import the packed tarballs
run: node scripts/release/smoke.ts --dir release-packages
- id: commit
name: Commit and tag
env:
VERSION: ${{ steps.release.outputs.version }}
CHANNEL: ${{ steps.release.outputs.channel }}
GITHUB_TOKEN: ${{ github.token }}
run: bash scripts/release/commit.sh
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: release-packages
path: release-packages/*.tgz
if-no-files-found: error
retention-days: 7
publish:
name: Publish
needs: build
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
ref: ${{ needs.build.outputs.sha }}
fetch-depth: 0
- name: Setup pnpm and Node.js
uses: pnpm/setup@703c52620218391530e48b9e8870d5c0082e1b9b # v2.1.0
with:
cache: true
install: false
# Release scripts import changelogithub and effect, but publishing does
# not need package lifecycle scripts.
- name: Install dependencies
run: pnpm install --frozen-lockfile --ignore-scripts
- name: Remove token-based npm authentication
run: sed -i '/always-auth/d' ~/.npmrc 2>/dev/null || true
- name: Download release artifacts
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: release-packages
path: release-packages
- name: Publish tarballs with OIDC
env:
DIST_TAG: ${{ needs.build.outputs.dist-tag }}
run: node scripts/release/publish.ts --tag "$DIST_TAG"
- name: Create GitHub release
if: needs.build.outputs.channel != 'tag'
env:
GITHUB_TOKEN: ${{ github.token }}
VERSION: ${{ needs.build.outputs.version }}
CHANNEL: ${{ needs.build.outputs.channel }}
run: node scripts/release/github-release.ts "v${VERSION}" "$CHANNEL"
- name: Notify Discord
if: needs.build.outputs.channel != 'tag'
env:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK_URL }}
VERSION: ${{ needs.build.outputs.version }}
CHANNEL: ${{ needs.build.outputs.channel }}
run: node scripts/release/discord-notify.ts "v${VERSION}" "$CHANNEL"