-
Notifications
You must be signed in to change notification settings - Fork 52
feat: add versions.json version metadata contract #110
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+82
−1
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
704d496
feat: add versions.json version metadata contract
ryzrr 58f784b
feat: add update-versions.mjs and release.yml workflow
ryzrr eaa8c69
Update versions.json
ryzrr f856e96
Update scripts/update-versions.mjs
ryzrr f818af1
Update .github/workflows/release.yml
ryzrr b4cfc63
fix: remove from script call and fix typo in PR title
ryzrr 3648701
chore: add versions.json to .prettierignore
ryzrr 3546d80
style: fix prettier formatting
ryzrr File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| name: Release | ||
|
|
||
| on: | ||
| workflow_dispatch: | ||
| inputs: | ||
| tag: | ||
| description: 'Release tag (e.g. v5.99.0)' | ||
| required: true | ||
| type: string | ||
| commit: | ||
| description: 'Target commit SHA or branch' | ||
| required: true | ||
| type: string | ||
|
|
||
| permissions: | ||
| contents: write | ||
| pull-requests: write | ||
|
|
||
| jobs: | ||
| sync: | ||
| runs-on: ubuntu-latest | ||
| env: | ||
| TAG: ${{ inputs.tag }} | ||
| COMMIT: ${{ inputs.commit }} | ||
|
|
||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | ||
|
|
||
| - name: Setup Node.js | ||
| uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0 | ||
| with: | ||
| node-version: lts/* | ||
| cache: 'npm' | ||
|
|
||
| - name: Install dependencies | ||
| run: npm ci | ||
|
|
||
| - name: Update files | ||
| shell: bash | ||
| run: | | ||
| set -euo pipefail | ||
| node scripts/update-versions.mjs "$TAG" | ||
|
ryzrr marked this conversation as resolved.
ryzrr marked this conversation as resolved.
|
||
| echo "$COMMIT" > HEAD_COMMIT | ||
|
|
||
| - name: Open pull request | ||
| uses: peter-evans/create-pull-request@5f6978faf089d4d20b00c7766989d076bb2fc7f1 # v8.1.1 | ||
| with: | ||
| token: ${{ secrets.GITHUB_TOKEN }} | ||
|
ryzrr marked this conversation as resolved.
|
||
| commit-message: 'chore: sync to webpack@${{ env.TAG }}' | ||
| title: 'chore: sync to webpack@${{ env.TAG }}' | ||
| body: | | ||
| Automated version sync triggered by the `${{ env.TAG }}` release of `${{ env.COMMIT }}`. | ||
| branch: 'update-versions' | ||
| draft: true | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,4 +3,5 @@ out | |
| *.generated.* | ||
| /webpack | ||
| pages | ||
| .husky | ||
| .husky | ||
| versions.json | ||
|
avivkeller marked this conversation as resolved.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| import { readFileSync, writeFileSync } from 'node:fs'; | ||
| import { major, valid } from 'semver'; | ||
|
ryzrr marked this conversation as resolved.
|
||
|
|
||
| const VERSIONS_FILE = './versions.json'; | ||
|
|
||
| const [tag] = process.argv.slice(2); | ||
| if (!tag) throw new Error('Missing release tag (e.g. v5.108.0)'); | ||
| if (!valid(tag)) throw new Error(`"${tag}" is not a valid semver tag`); | ||
|
|
||
| const latestMajor = major(tag); | ||
| const data = JSON.parse(readFileSync(VERSIONS_FILE, 'utf8')); | ||
|
|
||
| const existingIndex = data.findIndex(v => major(v) === latestMajor); | ||
|
|
||
| if (existingIndex !== -1) { | ||
| data[existingIndex] = tag; | ||
| console.log(`Updated v${latestMajor}.x to ${tag}`); | ||
|
ryzrr marked this conversation as resolved.
|
||
| } else { | ||
| data.unshift(tag); | ||
| console.log(`Created new entry for v${latestMajor}.x: ${tag}`); | ||
|
ryzrr marked this conversation as resolved.
ryzrr marked this conversation as resolved.
|
||
| } | ||
|
ryzrr marked this conversation as resolved.
|
||
|
|
||
| writeFileSync(VERSIONS_FILE, JSON.stringify(data, null, 2)); | ||
| console.log('versions.json written'); | ||
|
ryzrr marked this conversation as resolved.
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| ["v5.107.1"] | ||
|
ryzrr marked this conversation as resolved.
ryzrr marked this conversation as resolved.
ryzrr marked this conversation as resolved.
ryzrr marked this conversation as resolved.
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.