Skip to content

Commit 386293c

Browse files
committed
Create release workflow
1 parent 6d42f17 commit 386293c

5 files changed

Lines changed: 66 additions & 25 deletions

File tree

.github/workflows/release.yml

Lines changed: 28 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,55 @@
1-
name: release
1+
name: Release
22

33
on:
4-
push:
5-
tags:
6-
- "v*"
7-
workflow_dispatch:
4+
release:
5+
types: [published]
86

97
# Remove default permissions of GITHUB_TOKEN for security
108
# https://docs.github.com/en/actions/using-jobs/assigning-permissions-to-jobs
11-
permissions: {}
9+
permissions:
10+
contents: write
11+
id-token: write
1212

1313
jobs:
1414
release:
15-
concurrency:
16-
group: release
17-
permissions:
18-
contents: write
19-
id-token: write
2015
runs-on: ubuntu-latest
21-
timeout-minutes: 20
2216
steps:
2317
- uses: actions/checkout@v4
2418
with:
19+
ref: ${{ github.event.release.target_commitish }}
2520
fetch-depth: 0
21+
2622
- uses: oven-sh/setup-bun@v2
2723
with:
2824
bun-version: latest
2925

26+
- name: Extract version from tag
27+
id: version
28+
run: |
29+
VERSION=${GITHUB_REF#refs/tags/v}
30+
echo "version=$VERSION" >> $GITHUB_OUTPUT
31+
echo "Publishing version: $VERSION"
32+
33+
- name: Update package versions
34+
run: ./scripts/update-version.sh ${{ steps.version.outputs.version }}
35+
3036
- name: Install dependencies
3137
run: bun install
3238

33-
- name: Build (stub)
34-
run: bun run dev:prepare
35-
36-
- name: Build project
39+
- name: Build packages
3740
run: bun run build
3841

3942
- name: Publish nuxt-auto-api to npm
4043
run: cd packages/nuxt-auto-api && npm publish --provenance --access public
41-
env:
42-
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
4344

4445
- name: Publish nuxt-auto-admin to npm
4546
run: cd packages/nuxt-auto-admin && npm publish --provenance --access public
46-
env:
47-
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
47+
48+
- name: Commit version updates
49+
run: |
50+
VERSION=${{ steps.version.outputs.version }}
51+
git config user.name "github-actions[bot]"
52+
git config user.email "github-actions[bot]@users.noreply.github.com"
53+
git add packages/*/package.json
54+
git commit -m "chore: update versions to $VERSION [skip ci]" || echo "No changes to commit"
55+
git push origin HEAD:${{ github.event.release.target_commitish }} || echo "No changes to push"

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@
2222
"lint:fix": "turbo run lint:fix",
2323
"test": "turbo run test",
2424
"typecheck": "turbo run typecheck",
25-
"automd": "automd --config .github/automd.json"
25+
"automd": "automd --config .github/automd.json",
26+
"version": "scripts/update-version.sh"
2627
},
2728
"devDependencies": {
2829
"@nuxt/eslint-config": "^1.11.0",

packages/nuxt-auto-admin/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
},
99
"license": "MIT",
1010
"type": "module",
11+
"publishConfig": {
12+
"access": "public"
13+
},
1114
"exports": {
1215
".": {
1316
"types": "./dist/types.d.mts",
@@ -28,7 +31,6 @@
2831
"scripts": {
2932
"build": "nuxt-module-build build",
3033
"dev:prepare": "nuxt-module-build build --stub && nuxt-module-build prepare",
31-
"release": "bun run lint && bun run test && bun run build && changelogen --release && npm publish && git push --follow-tags",
3234
"lint": "eslint .",
3335
"lint:fix": "eslint . --fix",
3436
"test": "vitest run",
@@ -44,7 +46,6 @@
4446
"@nuxt/schema": "^4.3.0",
4547
"@nuxt/test-utils": "^3.23.0",
4648
"typescript": "^5.9.3",
47-
"changelogen": "^0.6.2",
4849
"nuxt": "^4.3.0"
4950
}
5051
}

packages/nuxt-auto-api/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
},
99
"license": "MIT",
1010
"type": "module",
11+
"publishConfig": {
12+
"access": "public"
13+
},
1114
"exports": {
1215
".": {
1316
"types": "./dist/types.d.mts",
@@ -28,7 +31,6 @@
2831
"scripts": {
2932
"build": "nuxt-module-build build",
3033
"dev:prepare": "nuxt-module-build build --stub && nuxt-module-build prepare",
31-
"release": "bun run lint && bun run test && bun run build && changelogen --release && npm publish && git push --follow-tags",
3234
"lint": "eslint .",
3335
"lint:fix": "eslint . --fix",
3436
"test": "vitest run",
@@ -44,7 +46,6 @@
4446
"@nuxt/schema": "^4.3.0",
4547
"@nuxt/test-utils": "^3.23.0",
4648
"typescript": "^5.9.3",
47-
"changelogen": "^0.6.2",
4849
"nuxt": "^4.3.0"
4950
}
5051
}

scripts/update-version.sh

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/bin/bash
2+
3+
# Update version across all packages in the monorepo
4+
# Usage: ./scripts/update-version.sh <version>
5+
6+
set -e
7+
8+
VERSION=$1
9+
10+
if [ -z "$VERSION" ]; then
11+
echo "Error: Version argument is required"
12+
echo "Usage: ./scripts/update-version.sh <version>"
13+
echo "Example: ./scripts/update-version.sh 1.2.3"
14+
exit 1
15+
fi
16+
17+
echo "Updating packages to version $VERSION..."
18+
19+
# Update all package.json files in packages/*
20+
for package_dir in packages/*/; do
21+
if [ -f "${package_dir}package.json" ]; then
22+
package_name=$(basename "$package_dir")
23+
echo " - Updating $package_name"
24+
cd "$package_dir"
25+
npm version "$VERSION" --no-git-tag-version --allow-same-version
26+
cd - > /dev/null
27+
fi
28+
done
29+
30+
echo "✓ All packages updated to version $VERSION"

0 commit comments

Comments
 (0)