diff --git a/.github/workflows/update-release-metadata.yml b/.github/workflows/update-release-metadata.yml new file mode 100644 index 000000000..a8131eb5c --- /dev/null +++ b/.github/workflows/update-release-metadata.yml @@ -0,0 +1,37 @@ +name: Update Release Metadata + +on: + workflow_dispatch: + inputs: + newVersion: + description: version override + type: string + required: false + +jobs: + create-update-pr: + name: Create update PR + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup Node.js environment + uses: actions/setup-node@v4 + with: + node-version: lts/* + cache: npm + + - name: Update release metadata + run: node dev/update_release_metadata.mjs ${{ inputs.newVersion || '' }} + + - name: Create pull request + uses: peter-evans/create-pull-request@v7 + with: + title: Update release metadata + commit-message: update release metadata + branch: update-release-metadata + body: | + Updates the extension version in metadata files, triggering Firefox autoupdate and the "Please update XKit!" in-extension notification. + + Remember to confirm that the referenced version is released on Github, the .xpi file link works, and the Chrome web store has the referenced version available before merging this. diff --git a/dev/update_release_metadata.mjs b/dev/update_release_metadata.mjs new file mode 100644 index 000000000..6d466dbb5 --- /dev/null +++ b/dev/update_release_metadata.mjs @@ -0,0 +1,18 @@ +import fs from "node:fs"; +import process from "node:process"; + +const newVersion = process.argv[2] || JSON.parse(fs.readFileSync("manifest.json", "utf8")).version; + +const data = [ + "Extensions/dist/page/FirefoxUpdate.json", + "Extensions/dist/page/FirefoxUpdate.rdf", + "Extensions/dist/page/framework_version.json", +].map(filePath => ({ filePath, contents: fs.readFileSync(filePath, "utf8") })); + +const oldVersion = /7\.\d{1,2}.\d{1,2}/.exec(data[0].contents)[0]; + +console.log(`replacing ${oldVersion} with ${newVersion}`); + +data.forEach(({ filePath, contents }) => { + fs.writeFileSync(filePath, contents.replaceAll(oldVersion, newVersion), { flag: "w+" }); +});