-
Notifications
You must be signed in to change notification settings - Fork 0
84 lines (78 loc) · 2.58 KB
/
Copy pathrelease.yml
File metadata and controls
84 lines (78 loc) · 2.58 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
name: Release
on:
push:
tags: ["v*"]
permissions:
contents: write
id-token: write
jobs:
release-gate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: actions/setup-go@v7
with:
go-version-file: go.mod
- run: make lint
- run: make test
- run: make audit-public
goreleaser:
needs: release-gate
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
with:
fetch-depth: 0
- uses: actions/setup-go@v7
with:
go-version-file: go.mod
- uses: sigstore/cosign-installer@v3
- uses: goreleaser/goreleaser-action@v6
with:
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
HOMEBREW_TAP_GITHUB_TOKEN: ${{ secrets.HOMEBREW_TAP_GITHUB_TOKEN }}
npm-publish:
needs: goreleaser
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write # OIDC for npm trusted publishing
steps:
- uses: actions/checkout@v7
- uses: actions/setup-node@v7
with:
node-version: 24
registry-url: "https://registry.npmjs.org"
- name: Download release binaries
run: |
VERSION=${GITHUB_REF_NAME#v}
TAG=$GITHUB_REF_NAME
declare -A ARCHIVES=(
[darwin-arm64]="shellroute_${VERSION}_darwin_arm64_npm.tar.gz"
[darwin-x64]="shellroute_${VERSION}_darwin_amd64_npm.tar.gz"
[linux-arm64]="shellroute_${VERSION}_linux_arm64_npm.tar.gz"
[linux-x64]="shellroute_${VERSION}_linux_amd64_npm.tar.gz"
)
for PLATFORM in "${!ARCHIVES[@]}"; do
ARCHIVE="${ARCHIVES[$PLATFORM]}"
gh release download $TAG --pattern "$ARCHIVE" --dir /tmp
mkdir -p npm/cli-${PLATFORM}/bin
tar -xzf /tmp/$ARCHIVE -C npm/cli-${PLATFORM}/bin
chmod +x npm/cli-${PLATFORM}/bin/shellroute
done
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Update versions and publish
run: |
VERSION=${GITHUB_REF_NAME#v}
for dir in npm/shellroute npm/cli-*; do
jq --arg v "$VERSION" '.version = $v' $dir/package.json > tmp.json && mv tmp.json $dir/package.json
done
for dir in npm/cli-*; do
cd $dir && npm publish --access public && cd -
done
cd npm/shellroute
jq --arg v "$VERSION" '.optionalDependencies |= with_entries(.value = $v)' package.json > tmp.json && mv tmp.json package.json
npm publish --access public