Skip to content

Refactor browser ID retrieval and add return statements to signUp and… #91

Refactor browser ID retrieval and add return statements to signUp and…

Refactor browser ID retrieval and add return statements to signUp and… #91

Workflow file for this run

name: 'test'
on:
push:
branches: [main]
jobs:
build:
runs-on: ubuntu-latest
environment:
name: test
steps:
- uses: actions/checkout@v4
- name: Setup Node.js environment
uses: actions/setup-node@v3
with:
node-version: 18
- name: Install Puppeteer
run: npm install puppeteer
- name: Check version against latest release in Chrome Web Store
id: check_version
uses: actions/github-script@v6
with:
script: |
const fs = require('fs/promises');
const puppeteer = require('puppeteer');
const fetchVersionInfo = async () => {
try {
const data = await fs.readFile('./static/manifest.json', 'utf8');
const manifest = JSON.parse(data);
const currentVersion = manifest.version;
const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.goto(`https://chromewebstore.google.com/detail/holo-key-manager/${{ vars.CHROME_ID}}`);
const versionPattern = /<div[^>]*>Version<\/div><div[^>]*>(\d+\.\d+\.\d+)<\/div>/;
const text = await page.content();
const versionMatch = text.match(versionPattern);
const latestVersion = versionMatch ? versionMatch[1] : null;
await browser.close();
core.setOutput('abort', currentVersion === latestVersion ? 'true' : 'false');
} catch (error) {
core.setFailed(error.message);
}
};
fetchVersionInfo();
- name: Abort build if version matches
if: steps.check_version.outputs.abort == 'true'
run: |
echo "Version in manifest matches the latest release version in Chrome Web Store. Aborting build."
exit 1
- name: Install pnpm
run: npm install -g pnpm
- name: Install dependencies
run: pnpm install --frozen-lockfile=false
- name: Build extension
run: pnpm build
- name: Zip the build
run: |
cd build
zip -r ../build.zip .
cd ..
- name: Chrome upload & release
uses: mobilefirstllc/cws-publish@latest
continue-on-error: true
with:
action: publish
client_id: ${{ secrets.CHROME_CLIENT_ID }}
client_secret: ${{ secrets.CHROME_CLIENT_SECRET }}
refresh_token: ${{ secrets.CHROME_REFRESH_TOKEN }}
extension_id: ${{ vars.CHROME_ID }}
zip_file: build.zip
- name: Edge upload & release
uses: wdzeng/[email protected]
continue-on-error: true
with:
product-id: ${{ vars.EDGE_ID }}
zip-path: build.zip
client-id: ${{ secrets.EDGE_CLIENT_ID }}
client-secret: ${{ secrets.EDGE_CLIENT_SECRET }}
access-token-url: ${{ secrets.EDGE_ACCESS_TOKEN_URL }}
- name: Replace manifest
run: pnpm build:replaceForFirefox ${{ vars.FF_ID }}
- name: Build extension
run: pnpm build
- name: Zip the build
run: |
cd build
zip -r ../buildFF.zip .
cd ..
- name: Firefox upload & release
uses: cardinalby/[email protected]
with:
zipFilePath: buildFF.zip
extensionId: ${{ vars.FF_ID }}
jwtIssuer: ${{ secrets.FF_JWT_ISSUER }}
jwtSecret: ${{ secrets.FF_JWT_SECRET }}