Skip to content

Commit 73e2ea4

Browse files
feat: Add release router workflow to manage feature and latest releases
1 parent 378b043 commit 73e2ea4

File tree

3 files changed

+94
-7
lines changed

3 files changed

+94
-7
lines changed

.github/workflows/release-feature-branch.yaml

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,24 @@
11
name: Release (feature branch)
22

33
on:
4-
push:
5-
branches-ignore:
6-
- main
7-
pull_request: {}
4+
workflow_call:
5+
secrets:
6+
PLANETSCALE_CONNECTION_STRING:
7+
required: true
8+
NEON_CONNECTION_STRING:
9+
required: true
10+
NEON_HTTP_CONNECTION_STRING:
11+
required: true
12+
TIDB_CONNECTION_STRING:
13+
required: true
14+
XATA_API_KEY:
15+
required: true
16+
XATA_BRANCH:
17+
required: true
18+
LIBSQL_REMOTE_URL:
19+
required: true
20+
LIBSQL_REMOTE_TOKEN:
21+
required: true
822

923
jobs:
1024
test:
@@ -329,7 +343,7 @@ jobs:
329343
permissions:
330344
contents: read
331345
id-token: write
332-
# force empty so npm can use OIDC
346+
# force empty so npm can use OIDC
333347
env:
334348
NODE_AUTH_TOKEN: ""
335349
NPM_TOKEN: ""

.github/workflows/release-latest.yaml

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,24 @@
11
name: Release (latest)
22

3-
on: workflow_dispatch
3+
on:
4+
workflow_call:
5+
secrets:
6+
PLANETSCALE_CONNECTION_STRING:
7+
required: true
8+
NEON_CONNECTION_STRING:
9+
required: true
10+
NEON_HTTP_CONNECTION_STRING:
11+
required: true
12+
TIDB_CONNECTION_STRING:
13+
required: true
14+
XATA_API_KEY:
15+
required: true
16+
XATA_BRANCH:
17+
required: true
18+
LIBSQL_REMOTE_URL:
19+
required: true
20+
LIBSQL_REMOTE_TOKEN:
21+
required: true
422

523
jobs:
624
test:
@@ -287,7 +305,7 @@ jobs:
287305

288306
release:
289307
permissions:
290-
contents: read
308+
contents: write
291309
id-token: write
292310
needs:
293311
- test

.github/workflows/router.yaml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: Release Router
2+
3+
on:
4+
push:
5+
branches-ignore:
6+
- main
7+
pull_request:
8+
workflow_dispatch:
9+
10+
jobs:
11+
switch:
12+
runs-on: ubuntu-latest
13+
outputs:
14+
target: ${{ steps.route.outputs.target }}
15+
steps:
16+
- name: Route release
17+
id: route
18+
run: |
19+
HEAD_REPO="${{ github.event.pull_request.head.repo.full_name }}"
20+
if [[ "$GITHUB_EVENT_NAME" == "workflow_dispatch" && "${GITHUB_REF##*/}" == "main" ]]; then
21+
echo "target=latest" >> $GITHUB_OUTPUT
22+
# only run on all pushes or pull requests from forks
23+
elif [[ "$GITHUB_EVENT_NAME" == "push" ]] || [[ "$HEAD_REPO" != "$GITHUB_REPOSITORY" ]]; then
24+
echo "target=feature" >> $GITHUB_OUTPUT
25+
else
26+
echo "target=skip" >> $GITHUB_OUTPUT
27+
fi
28+
29+
run-feature:
30+
needs: switch
31+
if: needs.switch.outputs.target == 'feature'
32+
uses: ./.github/workflows/release-feature-branch.yaml
33+
secrets:
34+
PLANETSCALE_CONNECTION_STRING: ${{ secrets.PLANETSCALE_CONNECTION_STRING }}
35+
NEON_CONNECTION_STRING: ${{ secrets.NEON_CONNECTION_STRING }}
36+
NEON_HTTP_CONNECTION_STRING: ${{ secrets.NEON_CONNECTION_STRING }}
37+
TIDB_CONNECTION_STRING: ${{ secrets.TIDB_CONNECTION_STRING }}
38+
XATA_API_KEY: ${{ secrets.XATA_API_KEY }}
39+
XATA_BRANCH: ${{ secrets.XATA_BRANCH }}
40+
LIBSQL_REMOTE_URL: ${{ secrets.LIBSQL_REMOTE_URL }}
41+
LIBSQL_REMOTE_TOKEN: ${{ secrets.LIBSQL_REMOTE_TOKEN }}
42+
43+
run-latest:
44+
needs: switch
45+
if: needs.switch.outputs.target == 'latest'
46+
uses: ./.github/workflows/release-latest.yaml
47+
secrets:
48+
PLANETSCALE_CONNECTION_STRING: ${{ secrets.PLANETSCALE_CONNECTION_STRING }}
49+
NEON_CONNECTION_STRING: ${{ secrets.NEON_CONNECTION_STRING }}
50+
NEON_HTTP_CONNECTION_STRING: ${{ secrets.NEON_CONNECTION_STRING }}
51+
TIDB_CONNECTION_STRING: ${{ secrets.TIDB_CONNECTION_STRING }}
52+
XATA_API_KEY: ${{ secrets.XATA_API_KEY }}
53+
XATA_BRANCH: ${{ secrets.XATA_BRANCH }}
54+
LIBSQL_REMOTE_URL: ${{ secrets.LIBSQL_REMOTE_URL }}
55+
LIBSQL_REMOTE_TOKEN: ${{ secrets.LIBSQL_REMOTE_TOKEN }}

0 commit comments

Comments
 (0)