Skip to content

Commit

Permalink
Add release metadata action (#2153)
Browse files Browse the repository at this point in the history
  • Loading branch information
marcustyphoon authored Nov 17, 2024
1 parent 3d5f273 commit 9d175f6
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 0 deletions.
37 changes: 37 additions & 0 deletions .github/workflows/update-release-metadata.yml
Original file line number Diff line number Diff line change
@@ -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.
18 changes: 18 additions & 0 deletions dev/update_release_metadata.mjs
Original file line number Diff line number Diff line change
@@ -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+" });
});

0 comments on commit 9d175f6

Please sign in to comment.