Repository navigation
140 lines (126 loc) · 4.98 KB
/
Copy pathrelease.yml
File metadata and controls
140 lines (126 loc) · 4.98 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
name: Release
on:
workflow_dispatch:
inputs:
component:
description: What to release
required: true
type: choice
options:
- panel
- agent
version:
description: Version to release, without a leading "v" (e.g. 1.2.0 or 1.2.0-beta.1)
required: true
type: string
prerelease:
description: Mark the GitHub release as a pre-release
required: false
type: boolean
default: false
permissions:
contents: write
concurrency:
group: release-${{ inputs.component }}
cancel-in-progress: false
jobs:
release:
name: Release ${{ inputs.component }} v${{ inputs.version }}
runs-on: ubuntu-latest
env:
COMPONENT: ${{ inputs.component }}
VERSION: ${{ inputs.version }}
TAG: ${{ inputs.component }}-v${{ inputs.version }}
DATABASE_URL: postgresql://user:pass@localhost:5432/db
BETTER_AUTH_SECRET: ci-only-placeholder-not-a-real-secret
BETTER_AUTH_URL: http://localhost:3000
GH_TOKEN: ${{ github.token }}
steps:
# Full history so the previous tag for this component can be found for
# the release notes.
- name: Checkout
uses: actions/checkout@v6
with:
fetch-depth: 0
persist-credentials: false
- name: Validate version
run: |
if ! [[ "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.-]+)?$ ]]; then
echo "::error::'$VERSION' is not a valid version (expected e.g. 1.2.0 or 1.2.0-beta.1)"
exit 1
fi
if git rev-parse --verify --quiet "refs/tags/$TAG" > /dev/null; then
echo "::error::Tag $TAG already exists"
exit 1
fi
- name: Setup Node
uses: actions/setup-node@v6
with:
node-version: 24
- name: Setup Bun
uses: oven-sh/setup-bun@v2
with:
bun-version: 1.3.13
# Stamp the version into the component's package.json and its bun.lock
# workspace entry, so `--frozen-lockfile` still passes both here and when
# the install script runs it on a server.
- name: Set version
run: |
bun -e '
const { COMPONENT, VERSION } = process.env;
const dir = COMPONENT === "panel" ? "apps/web" : "apps/agent";
const name = COMPONENT === "panel" ? "@bytepanel/web" : "@bytepanel/agent";
const file = `${dir}/package.json`;
const pkg = await Bun.file(file).json();
pkg.version = VERSION;
await Bun.write(file, JSON.stringify(pkg, null, 2) + "\n");
const lock = await Bun.file("bun.lock").text();
const entry = new RegExp(String.raw`("name": "${name}",\s*"version": )"[^"]*"`);
if (!entry.test(lock)) throw new Error(`No bun.lock entry for ${name}`);
await Bun.write("bun.lock", lock.replace(entry, `$1"${VERSION}"`));
'
git diff --stat
- name: Install dependencies
run: bun install --frozen-lockfile
- name: Lint, types, tests and recipe validation
run: bunx turbo run lint types test validate
- name: Build and package the agent
if: inputs.component == 'agent'
env:
AGENT_COMMIT_SHA: ${{ github.sha }}
run: |
bun run build:agent
mkdir -p release/agent
cp apps/agent/dist/bytepanel-daemon release/agent/
cp apps/agent/install/bytepanel-daemon.service release/agent/
cp apps/agent/README.md apps/agent/LICENSE release/agent/
chmod +x release/agent/bytepanel-daemon
(cd release/agent && zip -r "../bytepanel-agent-v$VERSION-linux-x64.zip" .)
# The panel is shipped as the committed source with the stamped version;
# the install script removes the agent, installs dependencies and builds
# on the server. The build here only verifies this release compiles.
- name: Build and package the panel
if: inputs.component == 'panel'
env:
BYTEPANEL_COMMIT_SHA: ${{ github.sha }}
run: |
bun run build
mkdir -p release/panel
git archive HEAD | tar -x -C release/panel
cp apps/web/package.json release/panel/apps/web/package.json
cp bun.lock release/panel/bun.lock
(cd release/panel && zip -r "../bytepanel-panel-v$VERSION.zip" .)
- name: Checksums
working-directory: release
run: sha256sum *.zip | tee SHA256SUMS
- name: Create GitHub release
run: |
flags=(--generate-notes --target "$GITHUB_SHA" --title "${COMPONENT^} v$VERSION")
previous=$(git tag --list "$COMPONENT-v*" --sort=-v:refname | head -n 1)
if [ -n "$previous" ]; then
flags+=(--notes-start-tag "$previous")
fi
if [ "${{ inputs.prerelease }}" = "true" ]; then
flags+=(--prerelease)
fi
gh release create "$TAG" --repo "$GITHUB_REPOSITORY" "${flags[@]}" release/*.zip release/SHA256SUMS