Skip to content

Commit 3ab42f3

Browse files
committed
feat(ci): auto-release on every push to main
CI now bumps patch version, commits, tags, and triggers the release workflow automatically. No manual version bumping needed.
1 parent 15d69b4 commit 3ab42f3

File tree

3 files changed

+109
-7
lines changed

3 files changed

+109
-7
lines changed

.github/workflows/ci.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,46 @@ jobs:
4848

4949
- name: Build npm package
5050
run: pnpm --filter ./packages/openlinear build
51+
52+
auto-release:
53+
name: Auto Release
54+
needs: release-readiness
55+
if: github.event_name == 'push' && github.ref == 'refs/heads/main' && !startsWith(github.event.head_commit.message, 'release:')
56+
runs-on: ubuntu-latest
57+
timeout-minutes: 10
58+
permissions:
59+
contents: write
60+
steps:
61+
- name: Checkout
62+
uses: actions/checkout@v4
63+
with:
64+
token: ${{ secrets.GITHUB_TOKEN }}
65+
66+
- name: Setup pnpm
67+
uses: pnpm/action-setup@v4
68+
69+
- name: Setup Node
70+
uses: actions/setup-node@v4
71+
with:
72+
node-version: 22
73+
cache: pnpm
74+
75+
- name: Install dependencies
76+
run: pnpm install --frozen-lockfile
77+
78+
- name: Bump version, commit, tag, and push
79+
run: |
80+
set -euo pipefail
81+
bash ./scripts/bump-version.sh
82+
NEXT=$(node -p "require('./packages/openlinear/package.json').version")
83+
git config user.name "github-actions[bot]"
84+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
85+
git add -A
86+
git commit -m "release: v${NEXT}"
87+
git tag "v${NEXT}"
88+
git push origin main --tags
89+
90+
- name: Trigger release workflow
91+
env:
92+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
93+
run: gh workflow run release.yml -f tag="v$(node -p "require('./packages/openlinear/package.json').version")"

.github/workflows/release.yml

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,22 @@ on:
44
push:
55
tags:
66
- "v*"
7+
workflow_dispatch:
8+
inputs:
9+
tag:
10+
description: "Release tag (e.g. v0.1.44)"
11+
required: true
712

813
permissions:
914
contents: write
1015

1116
concurrency:
12-
group: release-${{ github.ref_name }}
17+
group: release-${{ inputs.tag || github.ref_name }}
1318
cancel-in-progress: false
1419

1520
env:
1621
TURBO_TELEMETRY_DISABLED: 1
22+
RELEASE_TAG: ${{ inputs.tag || github.ref_name }}
1723

1824
jobs:
1925
build-release:
@@ -39,6 +45,8 @@ jobs:
3945
steps:
4046
- name: Checkout
4147
uses: actions/checkout@v4
48+
with:
49+
ref: ${{ env.RELEASE_TAG }}
4250

4351
- name: Setup pnpm
4452
uses: pnpm/action-setup@v4
@@ -73,7 +81,7 @@ jobs:
7381
run: pnpm install --frozen-lockfile
7482

7583
- name: Verify release version metadata
76-
run: bash ./scripts/sync-aur-metadata.sh "${GITHUB_REF_NAME#v}"
84+
run: bash ./scripts/sync-aur-metadata.sh "${RELEASE_TAG#v}"
7785

7886
- name: Build sidecar artifacts
7987
run: bash ./scripts/build-sidecar.sh
@@ -97,7 +105,7 @@ jobs:
97105
TMP_DIR=$(mktemp -d)
98106
trap 'rm -rf "$TMP_DIR"' EXIT
99107
PORTABLE_TARBALL="$TMP_DIR/openlinear-linux-x64.tar.gz"
100-
bash ./scripts/package-linux-portable.sh "${GITHUB_REF_NAME#v}" "$PORTABLE_TARBALL"
108+
bash ./scripts/package-linux-portable.sh "${RELEASE_TAG#v}" "$PORTABLE_TARBALL"
101109
tar -xzf "$PORTABLE_TARBALL" -C "$TMP_DIR"
102110
timeout 15s "$TMP_DIR/openlinear-linux-x64/openlinear-sidecar" > "$TMP_DIR/sidecar.log" 2>&1 || true
103111
cat "$TMP_DIR/sidecar.log"
@@ -106,7 +114,7 @@ jobs:
106114
- name: Prepare release artifacts
107115
run: |
108116
set -euo pipefail
109-
VERSION=${GITHUB_REF_NAME#v}
117+
VERSION=${RELEASE_TAG#v}
110118
mkdir -p dist/release
111119
if [ "${{ runner.os }}" = "Linux" ]; then
112120
DEB=$(ls apps/desktop/src-tauri/target/release/bundle/deb/*.deb | head -n 1)
@@ -161,6 +169,8 @@ jobs:
161169
steps:
162170
- name: Checkout
163171
uses: actions/checkout@v4
172+
with:
173+
ref: ${{ env.RELEASE_TAG }}
164174

165175
- name: Setup pnpm
166176
uses: pnpm/action-setup@v4
@@ -178,7 +188,7 @@ jobs:
178188
- name: Verify tag matches package version
179189
run: |
180190
set -euo pipefail
181-
VERSION=${GITHUB_REF_NAME#v}
191+
VERSION=${RELEASE_TAG#v}
182192
PACKAGE_VERSION=$(node -p "require('./packages/openlinear/package.json').version")
183193
if [ "$VERSION" != "$PACKAGE_VERSION" ]; then
184194
echo "Tag version $VERSION does not match packages/openlinear/package.json version $PACKAGE_VERSION" >&2
@@ -207,9 +217,11 @@ jobs:
207217
steps:
208218
- name: Checkout
209219
uses: actions/checkout@v4
220+
with:
221+
ref: ${{ env.RELEASE_TAG }}
210222

211223
- name: Sync Arch package metadata
212-
run: bash ./scripts/sync-aur-metadata.sh "${GITHUB_REF_NAME#v}"
224+
run: bash ./scripts/sync-aur-metadata.sh "${RELEASE_TAG#v}"
213225

214226
- name: Publish to AUR
215227
uses: KSXGitHub/github-actions-deploy-aur@v3.0.1
@@ -222,4 +234,4 @@ jobs:
222234
commit_username: kaizen403
223235
commit_email: kaizen403@proton.me
224236
ssh_private_key: ${{ secrets.AUR_SSH_PRIVATE_KEY }}
225-
commit_message: "Update to ${{ github.ref_name }}"
237+
commit_message: "Update to ${{ env.RELEASE_TAG }}"

scripts/bump-version.sh

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#!/usr/bin/env bash
2+
# bump-version.sh — Bump the patch version across all version files
3+
#
4+
# Usage:
5+
# ./scripts/bump-version.sh # auto-increment patch
6+
# ./scripts/bump-version.sh 0.2.0 # set explicit version
7+
set -euo pipefail
8+
9+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
10+
ROOT_DIR="$(dirname "$SCRIPT_DIR")"
11+
12+
NPM_PKG="$ROOT_DIR/packages/openlinear/package.json"
13+
TAURI_CONF="$ROOT_DIR/apps/desktop/src-tauri/tauri.conf.json"
14+
15+
CURRENT=$(node -p "require('$NPM_PKG').version")
16+
17+
if [ -n "${1:-}" ]; then
18+
NEXT="$1"
19+
else
20+
IFS='.' read -r MAJOR MINOR PATCH <<< "$CURRENT"
21+
NEXT="$MAJOR.$MINOR.$((PATCH + 1))"
22+
fi
23+
24+
if [ "$CURRENT" = "$NEXT" ]; then
25+
echo "Already at $CURRENT, nothing to bump"
26+
exit 0
27+
fi
28+
29+
echo "Bumping $CURRENT$NEXT"
30+
31+
node -e "
32+
const fs = require('fs');
33+
const pkg = JSON.parse(fs.readFileSync('$NPM_PKG', 'utf8'));
34+
pkg.version = '$NEXT';
35+
fs.writeFileSync('$NPM_PKG', JSON.stringify(pkg, null, 2) + '\n');
36+
"
37+
38+
node -e "
39+
const fs = require('fs');
40+
const conf = JSON.parse(fs.readFileSync('$TAURI_CONF', 'utf8'));
41+
conf.version = '$NEXT';
42+
fs.writeFileSync('$TAURI_CONF', JSON.stringify(conf, null, 2) + '\n');
43+
"
44+
45+
bash "$SCRIPT_DIR/sync-aur-metadata.sh" "$NEXT"
46+
47+
echo "Done — all files bumped to $NEXT"

0 commit comments

Comments
 (0)