-
Notifications
You must be signed in to change notification settings - Fork 1
148 lines (128 loc) · 3.93 KB
/
Copy pathrelease.yml
File metadata and controls
148 lines (128 loc) · 3.93 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
name: Release
on:
push:
tags:
- 'v*'
permissions:
contents: write
env:
NPM_SCOPE: atopos31
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
include:
- goos: darwin
goarch: arm64
npm: darwin-arm64
os: darwin
cpu: arm64
- goos: darwin
goarch: amd64
npm: darwin-x64
os: darwin
cpu: x64
- goos: linux
goarch: arm64
npm: linux-arm64
os: linux
cpu: arm64
- goos: linux
goarch: amd64
npm: linux-x64
os: linux
cpu: x64
- goos: windows
goarch: amd64
npm: win32-x64
os: win32
cpu: x64
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: '1.23'
- name: Get version
id: ver
run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT
- name: Build binary
run: |
mkdir -p dist/bin
EXT=""; [ "${{ matrix.goos }}" = "windows" ] && EXT=".exe"
GOOS=${{ matrix.goos }} GOARCH=${{ matrix.goarch }} CGO_ENABLED=0 \
go build -ldflags="-s -w" -o dist/bin/agent-rss${EXT} ./cmd/agent-rss
[ "${{ matrix.goos }}" != "windows" ] && chmod +x dist/bin/agent-rss || true
- name: Create npm package
run: |
cat > dist/package.json << EOF
{
"name": "@${{ env.NPM_SCOPE }}/agent-rss-${{ matrix.npm }}",
"version": "${{ steps.ver.outputs.VERSION }}",
"description": "agent-rss binary for ${{ matrix.npm }}",
"os": ["${{ matrix.os }}"],
"cpu": ["${{ matrix.cpu }}"],
"scripts": {
"postinstall": "node postinstall.js"
},
"files": ["bin", "postinstall.js"],
"license": "MIT"
}
EOF
if [ "${{ matrix.goos }}" = "windows" ]; then
echo "// no-op for windows" > dist/postinstall.js
else
cat > dist/postinstall.js << 'SCRIPT'
const { chmodSync } = require("fs");
const { join } = require("path");
try { chmodSync(join(__dirname, "bin", "agent-rss"), 0o755); } catch {}
SCRIPT
fi
- uses: actions/upload-artifact@v4
with:
name: ${{ matrix.npm }}
path: dist/
publish:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '20'
registry-url: 'https://registry.npmjs.org'
- name: Get version
id: ver
run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT
- uses: actions/download-artifact@v4
with:
path: artifacts
- name: Publish platform packages
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: |
for dir in artifacts/*/; do
echo "Publishing ${dir}..."
npm publish "${dir}" --access public || true
done
- name: Publish main package
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: |
cd npm/agent-rss
VERSION=${{ steps.ver.outputs.VERSION }}
# Update all versions
node -e "
const fs = require('fs');
const pkg = JSON.parse(fs.readFileSync('package.json'));
pkg.version = '${VERSION}';
for (const k of Object.keys(pkg.optionalDependencies || {})) {
pkg.optionalDependencies[k] = '${VERSION}';
}
fs.writeFileSync('package.json', JSON.stringify(pkg, null, 2));
"
npm publish --access public
- name: Create GitHub Release
uses: softprops/action-gh-release@v1
with:
generate_release_notes: true