-
Notifications
You must be signed in to change notification settings - Fork 141
130 lines (115 loc) · 4.56 KB
/
Copy pathrelease.yml
File metadata and controls
130 lines (115 loc) · 4.56 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
name: Release
on:
# Changeset-powered releases
push:
branches:
- main
- "v*.x"
# Label-powered prereleases
pull_request:
types: [labeled, opened, reopened, synchronize]
jobs:
release:
if: github.event_name == 'push'
runs-on: ubuntu-latest
permissions:
contents: write
id-token: write
steps:
- uses: actions/checkout@v3
with:
persist-credentials: false
# Used to fetch all history so that changesets doesn't attempt to
# publish duplicate tags.
fetch-depth: 0
# Replaces `concurrency` - never cancels any jobs
- uses: softprops/turnstyle@v1
with:
poll-interval-seconds: 30
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- uses: ./.github/actions/setup-and-build
- run: node scripts/generateReleaseConfig.js
env:
BRANCH: ${{ github.ref_name }}
- uses: changesets/action@v1
id: changesets
with:
version: pnpm run release:version
publish: pnpm run release:all
title: ${{ github.ref_name == 'main' && 'Release @latest' || format('Release {0}', github.ref_name) }}
env:
GITHUB_TOKEN: ${{ secrets.CHANGESET_GITHUB_TOKEN }}
NODE_ENV: test # disable npm access checks; they don't work in CI
BRANCH: ${{ github.ref_name }}
generate-prerelease-matrix:
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- id: set-matrix
run: |
LABELS='${{ toJson(github.event.pull_request.labels.*.name) }}'
MATRIX=$(jq -n --arg labels "$LABELS" '
($labels | fromjson) as $labelList |
[
{package: "inngest", dist_dir: "dist"},
{package: "eslint-plugin"},
{package: "middleware-sentry"},
{package: "middleware-encryption", dist_dir: "dist"},
{package: "test"},
{package: "ai"},
{package: "realtime", dist_dir: "dist"},
{package: "otel", dist_dir: "dist"},
{package: "middleware-validation", dist_dir: "dist"}
] | map(. as $pkg | select($labelList | index("prerelease/" + $pkg.package)))
')
echo "matrix=$(jq -cn --argjson data "$MATRIX" '{include: $data}')" >> $GITHUB_OUTPUT
prereleases:
needs: generate-prerelease-matrix
concurrency: prerelease-${{ github.ref }}
continue-on-error: true
strategy:
matrix: ${{ fromJson(needs.generate-prerelease-matrix.outputs.matrix) }}
runs-on: ubuntu-latest
permissions:
contents: write
id-token: write
defaults:
run:
working-directory: packages/${{ matrix.package }}
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- uses: ./.github/actions/setup-and-build
with:
install-dependencies: true
build: ${{ matrix.package == 'inngest' }}
- run: pnpm build
if: matrix.package != 'inngest'
- run: pnpm run test
if: matrix.package == 'otel'
- name: Prerelease PR
run: |
export TAG=pr-${{ github.event.pull_request.number }}
export NODE_ENV=test
[[ -n "${{ matrix.dist_dir }}" ]] && export DIST_DIR=${{ matrix.dist_dir }}
node ../../scripts/release/prerelease.js
- name: Update PR with latest prerelease
uses: edumserrano/find-create-or-update-comment@v1
with:
token: ${{ secrets.CHANGESET_GITHUB_TOKEN }}
issue-number: ${{ github.event.pull_request.number }}
body-includes: "<!-- pr-prerelease-comment-${{ matrix.package }} -->"
comment-author: "inngest-release-bot"
edit-mode: "replace"
body: |
<!-- pr-prerelease-comment-${{ matrix.package }} -->
A user has added the <kbd>[prerelease/${{ matrix.package }}](https://github.com/inngest/inngest-js/labels/prerelease%2F${{ matrix.package }})</kbd> label, so this PR will be published to npm with the tag `pr-${{ github.event.pull_request.number }}`. It will be updated with the latest changes as you push commits to this PR.
You can install this prerelease version with:
```sh
npm install ${{ matrix.package == 'inngest' && 'inngest' || format('@inngest/{0}', matrix.package) }}@pr-${{ github.event.pull_request.number }}
```
The last release was built and published from ${{ github.event.pull_request.head.sha }}.