Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions .github/workflows/release.yml
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
Comment thread
ryzrr marked this conversation as resolved.

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"
Comment thread
ryzrr marked this conversation as resolved.
Comment thread
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 }}
Comment thread
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
3 changes: 2 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ out
*.generated.*
/webpack
pages
.husky
.husky
versions.json
24 changes: 24 additions & 0 deletions scripts/update-versions.mjs
Comment thread
avivkeller marked this conversation as resolved.
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';
Comment thread
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}`);
Comment thread
ryzrr marked this conversation as resolved.
} else {
data.unshift(tag);
console.log(`Created new entry for v${latestMajor}.x: ${tag}`);
Comment thread
ryzrr marked this conversation as resolved.
Comment thread
ryzrr marked this conversation as resolved.
}
Comment thread
ryzrr marked this conversation as resolved.

writeFileSync(VERSIONS_FILE, JSON.stringify(data, null, 2));
console.log('versions.json written');
Comment thread
ryzrr marked this conversation as resolved.
1 change: 1 addition & 0 deletions versions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
["v5.107.1"]
Comment thread
ryzrr marked this conversation as resolved.
Comment thread
ryzrr marked this conversation as resolved.
Comment thread
ryzrr marked this conversation as resolved.
Comment thread
ryzrr marked this conversation as resolved.