-
Notifications
You must be signed in to change notification settings - Fork 160
75 lines (62 loc) · 2.11 KB
/
Copy pathrelease.yml
File metadata and controls
75 lines (62 loc) · 2.11 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
name: Release
on:
push:
tags:
- 'v*'
permissions:
contents: write
jobs:
release:
runs-on: blacksmith-4vcpu-ubuntu-2404
steps:
- uses: actions/checkout@v4
- name: Validate and read release version
id: version
shell: bash
run: |
set -euo pipefail
version="${GITHUB_REF_NAME#v}"
[[ "${GITHUB_REF_NAME}" =~ ^v[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.-]+)?$ ]] \
|| { echo "Tag '${GITHUB_REF_NAME}' must be a SemVer tag such as v1.2.3"; exit 1; }
echo "version=${version}" >> "$GITHUB_OUTPUT"
- uses: oven-sh/setup-bun@v2
- run: bun install
- run: bun run build
env:
VERSION: ${{ steps.version.outputs.version }}
- name: Pack npm tarball
id: npm-package
env:
VERSION: ${{ steps.version.outputs.version }}
shell: bash
run: |
set -euo pipefail
staging_dir="$(mktemp -d)"
trap 'rm -rf "$staging_dir"' EXIT
cp package.json "$staging_dir/package.json"
cp -R dist "$staging_dir/dist"
node -e '
const fs = require("fs");
const path = process.argv[1];
const pkg = JSON.parse(fs.readFileSync(path, "utf8"));
pkg.version = process.env.VERSION;
fs.writeFileSync(path, `${JSON.stringify(pkg, null, 2)}\n`);
' "$staging_dir/package.json"
npm pack "$staging_dir" --pack-destination . --ignore-scripts
tarball="mmx-cli-${VERSION}.tgz"
test -f "$tarball"
echo "path=${tarball}" >> "$GITHUB_OUTPUT"
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
generate_release_notes: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/setup-node@v4
with:
node-version: '20'
registry-url: 'https://registry.npmjs.org'
- name: Publish to npm
run: npm publish "${{ steps.npm-package.outputs.path }}" --ignore-scripts
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}