Skip to content

Commit 5992167

Browse files
committed
refactor: streamline release workflows to trigger on CI success and enhance version handling
1 parent 675af9e commit 5992167

6 files changed

Lines changed: 178 additions & 118 deletions

File tree

.github/workflows/app-release.yml

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,29 @@
11
name: App Release (reusable)
22

33
# Generalized release workflow for apps built on Eclipse Docks: publishes a GitHub
4-
# Release when triggered by a vX.Y.Z tag push (see @eclipse-docks/cli's `docks release`
5-
# command), then optionally builds and deploys the app to GitHub Pages. Call from a
6-
# per-app workflow, e.g.:
4+
# Release for a vX.Y.Z tag (see @eclipse-docks/cli's `docks release` command), then
5+
# optionally builds and deploys the app to GitHub Pages.
6+
#
7+
# Prefer triggering from a Release workflow after CI succeeds on main, passing
8+
# `version`. Tag-push callers may omit `version` and rely on GITHUB_REF instead.
79
#
810
# on:
9-
# push:
10-
# tags:
11-
# - v*
11+
# workflow_run:
12+
# workflows: [CI]
13+
# types: [completed]
1214
#
1315
# jobs:
16+
# resolve:
17+
# if: github.event.workflow_run.conclusion == 'success'
18+
# ...
19+
#
1420
# release:
15-
# permissions:
16-
# contents: write
21+
# needs: resolve
1722
# uses: eclipse-docks/core/.github/workflows/app-release.yml@main
1823
# with:
24+
# version: ${{ needs.resolve.outputs.version }}
1925
# base_path: /my-app/
2026
# publish_dir: ./packages/app/dist
21-
# # publish_branch: gh-pages # optional; created as an orphan if missing
2227
# secrets: inherit
2328

2429
on:
@@ -60,6 +65,10 @@ on:
6065
description: "Git branch to publish the built app to (created as an orphan branch if it does not exist)"
6166
type: string
6267
default: gh-pages
68+
version:
69+
description: "Release tag (e.g. v1.2.3). When empty, derived from a vX.Y.Z tag push ref."
70+
type: string
71+
default: ""
6372
outputs:
6473
version:
6574
description: "The released version tag (e.g. v1.2.3; empty if this run was not triggered by a release tag)"
@@ -82,8 +91,11 @@ jobs:
8291
- name: Resolve release tag and notes
8392
id: version
8493
run: |
85-
TAG="${GITHUB_REF#refs/tags/}"
86-
echo "Ref tag: $TAG"
94+
TAG="${{ inputs.version }}"
95+
if [ -z "$TAG" ]; then
96+
TAG="${GITHUB_REF#refs/tags/}"
97+
fi
98+
echo "Release tag: $TAG"
8799
88100
if ! printf '%s\n' "$TAG" | grep -qE '^v[0-9]+\.[0-9]+\.[0-9]+$'; then
89101
echo "Not a release tag: $TAG"

.github/workflows/ci.yml

Lines changed: 0 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ on:
44
push:
55
branches:
66
- main
7-
tags:
8-
- v*
97
pull_request:
108
branches:
119
- main
@@ -52,103 +50,3 @@ jobs:
5250

5351
- name: Run E2E tests
5452
run: npm run test:e2e
55-
56-
release:
57-
needs: test
58-
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') && needs.test.result == 'success'
59-
permissions:
60-
contents: write
61-
uses: ./.github/workflows/app-release.yml
62-
with:
63-
publish_dir: packages/app/dist
64-
build_command: npm run build:app
65-
node_version_file: .nvmrc
66-
cname: docks.eclipse.dev
67-
secrets: inherit
68-
69-
deploy-docs:
70-
needs: release
71-
if: needs.release.outputs.version != ''
72-
runs-on: ubuntu-latest
73-
permissions:
74-
contents: write
75-
steps:
76-
- name: Checkout code
77-
uses: actions/checkout@v7
78-
79-
- name: Set up Node.js
80-
uses: actions/setup-node@v7
81-
with:
82-
node-version-file: '.nvmrc'
83-
cache: npm
84-
85-
- name: Install dependencies
86-
run: npm ci
87-
88-
- name: Build docs
89-
env:
90-
DOCKS_DOCS_VERSION: ${{ needs.release.outputs.version }}
91-
run: npm run docs:build
92-
93-
- name: Deploy docs to GitHub Pages
94-
uses: peaceiris/actions-gh-pages@v4
95-
with:
96-
github_token: ${{ secrets.GITHUB_TOKEN }}
97-
publish_dir: docs/.vitepress/dist
98-
destination_dir: docs
99-
publish_branch: gh-pages
100-
keep_files: true
101-
102-
publish-npm:
103-
needs: release
104-
if: needs.release.outputs.version != ''
105-
runs-on: ubuntu-latest
106-
permissions:
107-
contents: read
108-
id-token: write
109-
steps:
110-
- name: Checkout code
111-
uses: actions/checkout@v7
112-
with:
113-
fetch-depth: 0
114-
115-
- name: Setup Node.js
116-
uses: actions/setup-node@v7
117-
with:
118-
node-version-file: '.nvmrc'
119-
registry-url: "https://registry.npmjs.org"
120-
cache: npm
121-
122-
- name: Install dependencies
123-
run: npm ci
124-
125-
- name: Update package versions (CI only, not committed)
126-
run: |
127-
VERSION="${{ needs.release.outputs.version }}"
128-
VERSION="${VERSION#v}"
129-
for pkg in packages/core packages/extension-* packages/create-app packages/cli; do
130-
[ -d "$pkg" ] && (cd "$pkg" && npm version "$VERSION" --no-git-tag-version) && echo "Updated $pkg to $VERSION"
131-
done
132-
133-
- name: Build core package
134-
run: npm run build
135-
136-
- name: Build extension packages
137-
run: npm run build:extensions
138-
139-
- name: Run type check
140-
run: npm run type-check
141-
continue-on-error: true
142-
143-
- name: Publish core, extensions, create-app, and cli to npm
144-
run: |
145-
for pkg in packages/core packages/extension-* packages/create-app packages/cli; do
146-
if [ -d "$pkg" ]; then
147-
if grep -q '"private":\s*true' "$pkg/package.json" 2>/dev/null; then
148-
echo "Skipping $pkg (private)"
149-
else
150-
echo "Publishing $pkg..."
151-
(cd "$pkg" && npm publish --access public --provenance)
152-
fi
153-
fi
154-
done

.github/workflows/release.yml

Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
name: Release
2+
3+
# Runs after CI succeeds on a main-branch push. Releases only when that commit has a
4+
# vX.Y.Z tag (created by `docks release`).
5+
on:
6+
workflow_run:
7+
workflows: [CI]
8+
types: [completed]
9+
10+
permissions:
11+
actions: read
12+
contents: write
13+
id-token: write
14+
15+
jobs:
16+
resolve:
17+
if: >
18+
github.event.workflow_run.conclusion == 'success' &&
19+
github.event.workflow_run.event == 'push' &&
20+
github.event.workflow_run.head_branch == 'main'
21+
runs-on: ubuntu-latest
22+
outputs:
23+
version: ${{ steps.tag.outputs.version }}
24+
steps:
25+
- name: Checkout tested commit
26+
uses: actions/checkout@v7
27+
with:
28+
ref: ${{ github.event.workflow_run.head_sha }}
29+
fetch-depth: 0
30+
31+
- name: Find release tag on commit
32+
id: tag
33+
run: |
34+
TAG=$(git tag --points-at HEAD | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+$' | head -1 || true)
35+
if [ -z "$TAG" ]; then
36+
echo "No release tag on ${{ github.event.workflow_run.head_sha }}; skipping release."
37+
else
38+
echo "Release tag: $TAG"
39+
fi
40+
echo "version=$TAG" >> $GITHUB_OUTPUT
41+
42+
release:
43+
needs: resolve
44+
if: needs.resolve.outputs.version != ''
45+
permissions:
46+
contents: write
47+
uses: ./.github/workflows/app-release.yml
48+
with:
49+
version: ${{ needs.resolve.outputs.version }}
50+
publish_dir: packages/app/dist
51+
build_command: npm run build:app
52+
node_version_file: .nvmrc
53+
cname: docks.eclipse.dev
54+
secrets: inherit
55+
56+
deploy-docs:
57+
needs: release
58+
if: needs.release.outputs.version != ''
59+
runs-on: ubuntu-latest
60+
permissions:
61+
contents: write
62+
steps:
63+
- name: Checkout code
64+
uses: actions/checkout@v7
65+
with:
66+
ref: ${{ needs.release.outputs.version }}
67+
68+
- name: Set up Node.js
69+
uses: actions/setup-node@v7
70+
with:
71+
node-version-file: '.nvmrc'
72+
cache: npm
73+
74+
- name: Install dependencies
75+
run: npm ci
76+
77+
- name: Build docs
78+
env:
79+
DOCKS_DOCS_VERSION: ${{ needs.release.outputs.version }}
80+
run: npm run docs:build
81+
82+
- name: Deploy docs to GitHub Pages
83+
uses: peaceiris/actions-gh-pages@v4
84+
with:
85+
github_token: ${{ secrets.GITHUB_TOKEN }}
86+
publish_dir: docs/.vitepress/dist
87+
destination_dir: docs
88+
publish_branch: gh-pages
89+
keep_files: true
90+
91+
publish-npm:
92+
needs: release
93+
if: needs.release.outputs.version != ''
94+
runs-on: ubuntu-latest
95+
permissions:
96+
contents: read
97+
id-token: write
98+
steps:
99+
- name: Checkout code
100+
uses: actions/checkout@v7
101+
with:
102+
ref: ${{ needs.release.outputs.version }}
103+
fetch-depth: 0
104+
105+
- name: Setup Node.js
106+
uses: actions/setup-node@v7
107+
with:
108+
node-version-file: '.nvmrc'
109+
registry-url: "https://registry.npmjs.org"
110+
cache: npm
111+
112+
- name: Install dependencies
113+
run: npm ci
114+
115+
- name: Update package versions (CI only, not committed)
116+
run: |
117+
VERSION="${{ needs.release.outputs.version }}"
118+
VERSION="${VERSION#v}"
119+
for pkg in packages/core packages/extension-* packages/create-app packages/cli; do
120+
[ -d "$pkg" ] && (cd "$pkg" && npm version "$VERSION" --no-git-tag-version) && echo "Updated $pkg to $VERSION"
121+
done
122+
123+
- name: Build core package
124+
run: npm run build
125+
126+
- name: Build extension packages
127+
run: npm run build:extensions
128+
129+
- name: Run type check
130+
run: npm run type-check
131+
continue-on-error: true
132+
133+
- name: Publish core, extensions, create-app, and cli to npm
134+
run: |
135+
for pkg in packages/core packages/extension-* packages/create-app packages/cli; do
136+
if [ -d "$pkg" ]; then
137+
if grep -q '"private":\s*true' "$pkg/package.json" 2>/dev/null; then
138+
echo "Skipping $pkg (private)"
139+
else
140+
echo "Publishing $pkg..."
141+
(cd "$pkg" && npm publish --access public --provenance)
142+
fi
143+
fi
144+
done

packages/cli/README.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,11 @@ npx @eclipse-docks/cli release --no-push # create the tag locally wi
1818

1919
Creates an annotated tag whose name is the version (`vX.Y.Z`) and pushes it.
2020
When pushing (the default), any unpushed commits on the current branch are pushed
21-
to `origin` first so CI builds code that is on the remote branch, not only reachable
22-
via the tag. Pair this with a CI workflow triggered by `v*` tag pushes (see
23-
[`.github/workflows/app-release.yml`](../../.github/workflows/app-release.yml) for a
24-
reusable one) — the tag message body becomes the GitHub Release notes.
21+
to `origin` first. The tag message body becomes the GitHub Release notes.
22+
23+
Wire release in CI with [`.github/workflows/app-release.yml`](../../.github/workflows/app-release.yml):
24+
downstream apps usually trigger it on `v*` tag push; this monorepo waits for a green
25+
**CI** run on `main` first (see [`.github/workflows/release.yml`](../../.github/workflows/release.yml)).
2526

2627
The last version is the most recent `vX.Y.Z` tag reachable from `HEAD` (via
2728
`git describe`), not the highest semver tag in the repository. That drives the

packages/create-app/template/.github/workflows/release.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
name: Release
22

3+
# Pushing any vX.Y.Z tag creates a GitHub Release and deploys the production build
4+
# from packages/app/dist to GitHub Pages (the tag may be created with `docks release`
5+
# or manually). Adapt inputs below for your setup, or delete this file if you release
6+
# another way.
7+
38
on:
49
push:
510
tags:

packages/create-app/template/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Then open the URL shown in the terminal (e.g. https://localhost:5173/).
1515
- **dev** – Start the development server
1616
- **build** – Build for production
1717
- **preview** – Preview the production build locally
18-
- **release** – Create an annotated release tag (`docks release`); pushing the tag triggers `.github/workflows/release.yml`, which creates a GitHub Release and deploys to GitHub Pages
18+
- **release** – Create an annotated release tag (`docks release`); pushing the tag runs `.github/workflows/release.yml`, which creates a GitHub Release and deploys to GitHub Pages
1919

2020
## Structure
2121

0 commit comments

Comments
 (0)