-
Notifications
You must be signed in to change notification settings - Fork 8
107 lines (96 loc) · 3.36 KB
/
Copy pathrelease.yml
File metadata and controls
107 lines (96 loc) · 3.36 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
name: Release on tag
on:
push:
tags:
- "v*"
workflow_dispatch:
permissions:
id-token: write
contents: write
jobs:
build-native:
strategy:
matrix:
platform:
# The x86_64 Linux prebuild is generated when running pnpm turbo run build in the `build` job
- runs-on: codspeedhq-arm64-ubuntu-22.04
name: linux-arm
- runs-on: macos-latest
name: darwin-arm
runs-on: ${{ matrix.platform.runs-on }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: true
- uses: pnpm/action-setup@v4
- uses: actions/setup-node@v6
with:
cache: pnpm
node-version-file: .nvmrc
- run: pnpm install --frozen-lockfile --prefer-offline
- name: Build native addon
run: pnpm turbo run build-native-addon --filter=@codspeed/core
- name: Upload prebuilds
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.platform.name }}-prebuilds
path: packages/core/prebuilds
build:
runs-on: ubuntu-latest
needs: build-native
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: true
- uses: pnpm/action-setup@v4
- uses: actions/setup-node@v6
with:
cache: pnpm
node-version-file: .nvmrc
registry-url: "https://registry.npmjs.org"
- run: pnpm install --frozen-lockfile --prefer-offline
- name: Build the libraries
run: pnpm turbo run build
- name: Download prebuilds
uses: actions/download-artifact@v4
with:
pattern: "*-prebuilds"
merge-multiple: true
path: packages/core/prebuilds
- if: github.event_name == 'push'
name: Publish the libraries
run: |
# Prerelease tags publish under their own identifier (alpha, beta, rc);
# only a plain vX.Y.Z tag is allowed to move the `latest` dist-tag.
VERSION="${GITHUB_REF_NAME#v}"
if [[ "$VERSION" != *-* ]]; then
pnpm publish -r --access=public --no-git-checks
exit 0
fi
PREID="${VERSION#*-}"
PREID="${PREID%%.*}"
# npm rejects a dist-tag that parses as a semver range, so a numeric
# identifier has no channel to publish under, and `latest` is the
# stable channel a prerelease must never take over.
if [[ ! "$PREID" =~ ^[A-Za-z][A-Za-z0-9-]*$ || "${PREID,,}" == "latest" ]]; then
echo "Refusing to publish $GITHUB_REF_NAME: '$PREID' cannot be a prerelease dist-tag" >&2
exit 1
fi
pnpm publish -r --access=public --no-git-checks --tag="$PREID"
env:
NPM_CONFIG_PROVENANCE: true
# Surfaces npm's OIDC token exchange, which is otherwise silent.
NPM_CONFIG_LOGLEVEL: verbose
- if: github.event_name == 'push'
name: Create a draft release
run: |
NEW_VERSION=$(pnpm lerna list --json | jq -r '.[] | select(.name == "@codspeed/core") | .version')
PRERELEASE=""
if [[ "$NEW_VERSION" == *-* ]]; then
PRERELEASE="--prerelease"
fi
gh release create "v$NEW_VERSION" --title "v$NEW_VERSION" --generate-notes -d $PRERELEASE
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}