forked from firebase/firebase-tools
-
Notifications
You must be signed in to change notification settings - Fork 7
136 lines (117 loc) · 4.96 KB
/
Copy pathupdate-isolate.yml
File metadata and controls
136 lines (117 loc) · 4.96 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
name: Update isolate-package
# Updates the isolate-package dependency to a new version, bumps the fork's
# pre-release number, pushes to main, and triggers the Publish workflow
# to release the update to npm as the 'next' tag.
#
# Use this when you've published a pre-release of isolate-package and want to
# test it within the firebase-tools-with-isolate fork.
#
# The Publish workflow is triggered as a fresh workflow_dispatch rather than
# chained via workflow_call. npm's trusted publishing validates the OIDC
# token against the *calling* workflow's filename, not the reusable one, so
# a workflow_call from here would be rejected (404) by the trusted publisher
# configured for publish.yml. Dispatching gives publish.yml its own OIDC
# context where workflow_ref matches the trust config.
on:
workflow_dispatch:
inputs:
isolate_version:
description: "isolate-package version (e.g. 2.0.0-beta.1, or a dist-tag like 'next')"
required: true
type: string
dry_run:
description: "Dry run — skip push and publish"
required: false
type: boolean
default: false
concurrency:
group: update-isolate
cancel-in-progress: false
jobs:
update:
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
permissions:
contents: write
actions: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 24
- name: Configure git
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
- name: Resolve isolate-package version
id: isolate
env:
INPUT_VERSION: ${{ inputs.isolate_version }}
run: |
# If the input is a dist-tag (like "next" or "latest"), resolve it
if [[ "$INPUT_VERSION" =~ ^[a-z]+$ ]]; then
RESOLVED=$(npm view "isolate-package@$INPUT_VERSION" version)
echo "Resolved dist-tag '$INPUT_VERSION' → $RESOLVED"
echo "version=$RESOLVED" >> "$GITHUB_OUTPUT"
else
echo "version=$INPUT_VERSION" >> "$GITHUB_OUTPUT"
fi
- name: Update dependency
env:
ISOLATE_VERSION: ${{ steps.isolate.outputs.version }}
run: |
echo "Updating isolate-package to $ISOLATE_VERSION"
npm pkg set "dependencies.isolate-package=$ISOLATE_VERSION"
- name: Install dependencies
run: npm install
- name: Build
run: npm run build
- name: Bump pre-release version
id: version
env:
ISOLATE_VERSION: ${{ steps.isolate.outputs.version }}
run: |
# Stage changes from npm pkg set + npm install so npm version
# doesn't fail on a dirty working directory. If the dependency
# was already at the requested version (e.g. when re-running to
# recover from a failed publish), skip this commit — we still
# want the pre-release bump below.
git add package.json npm-shrinkwrap.json
if ! git diff --cached --quiet; then
git commit -m "Update isolate-package to ${ISOLATE_VERSION}"
fi
# If the version has no prerelease suffix (e.g. after publishing to
# "latest" which strips it), restore the "-0" suffix first. Without
# this, npm version prerelease would bump the patch number
# (15.13.0 → 15.13.1-0) instead of the prerelease (15.13.0 → 15.13.0-0).
CURRENT=$(node -e "process.stdout.write(require('./package.json').version)")
if [[ "$CURRENT" != *-* ]]; then
npm version "${CURRENT}-0" --git-tag-version true
fi
npm version prerelease --git-tag-version true
VERSION=$(node -e "process.stdout.write(require('./package.json').version)")
TAG="v${VERSION}"
echo "version=${VERSION}" >> $GITHUB_OUTPUT
echo "tag=${TAG}" >> $GITHUB_OUTPUT
- name: Summary
env:
ISOLATE_VERSION: ${{ steps.isolate.outputs.version }}
run: |
echo "### Update isolate-package" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "- **isolate-package:** $ISOLATE_VERSION" >> $GITHUB_STEP_SUMMARY
echo "- **Fork version:** ${{ steps.version.outputs.version }}" >> $GITHUB_STEP_SUMMARY
echo "- **Tag:** ${{ steps.version.outputs.tag }}" >> $GITHUB_STEP_SUMMARY
echo "- **Dry run:** ${{ inputs.dry_run }}" >> $GITHUB_STEP_SUMMARY
- name: Push to main
if: ${{ inputs.dry_run == false }}
run: git push origin main
- name: Trigger publish workflow
if: ${{ inputs.dry_run == false }}
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: gh workflow run publish.yml --repo "$GITHUB_REPOSITORY" --ref main -f dist_tag=next