Skip to content
Open
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
49 changes: 49 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Build extension

on:
push:
branches:
- '**'
pull_request:
branches:
- '**'

jobs:
build-and-release:
name: Build
runs-on: ubuntu-latest
strategy:
matrix:
target: [ firefox, chrome ]

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: '20'

- name: Install dependencies
run: npm ci

- name: Build extension
run: TARGET=${{ matrix.target }} npm run build

- id: prepare_zip
name: Prepare ZIP
run: |
VERSION=$(node -e "console.log(require('./dist/${{ matrix.target }}/manifest.json').version)")
TIMESTAMP=$(git show -s --format=%cd --date=format:%Y-%m-%dT%H-%M-%S $GITHUB_SHA)
COMMIT_HASH=$(echo "$GITHUB_SHA" | cut -c1-7)
ZIP_NAME="OpenSwitchMaps-${{ matrix.target }}-${VERSION}-${TIMESTAMP}-${COMMIT_HASH}"
cd dist/${{ matrix.target }} && zip -r "../../$ZIP_NAME.zip" .
echo "zip_name=$ZIP_NAME" >> $GITHUB_OUTPUT
echo "version=$VERSION" >> $GITHUB_OUTPUT

- name: Upload ZIP artifact
uses: actions/upload-artifact@v4
with:
name: ${{ steps.prepare_zip.outputs.zip_name }}
path: ${{ steps.prepare_zip.outputs.zip_name }}.zip
52 changes: 52 additions & 0 deletions .github/workflows/publish_release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Build and publish extension release

on:
workflow_dispatch:

jobs:
build-and-release:
name: Build and publish
runs-on: ubuntu-latest
strategy:
matrix:
target: [ firefox, chrome ]

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: '20'

- name: Install dependencies
run: npm ci

- name: Build extension
run: TARGET=${{ matrix.target }} npm run build

- id: prepare_zip
name: Prepare ZIP
run: |
VERSION=$(node -e "console.log(require('./dist/${{ matrix.target }}/manifest.json').version)")
TIMESTAMP=$(git show -s --format=%cd --date=format:%Y-%m-%dT%H-%M-%S $GITHUB_SHA)
COMMIT_HASH=$(echo "$GITHUB_SHA" | cut -c1-7)
ZIP_NAME="OpenSwitchMaps-${{ matrix.target }}-${VERSION}-${TIMESTAMP}-${COMMIT_HASH}"
cd dist/${{ matrix.target }} && zip -r "../../$ZIP_NAME.zip" .
echo "zip_name=$ZIP_NAME" >> $GITHUB_OUTPUT
echo "version=$VERSION" >> $GITHUB_OUTPUT

- name: Create release
run: |
TAG="${{ steps.prepare_zip.outputs.version }}"
ZIP="${{ steps.prepare_zip.outputs.zip_name }}.zip"
if gh release view "$TAG" >/dev/null 2>&1; then
echo "Release $TAG exists, uploading asset..."
gh release upload "$TAG" "$ZIP" --clobber
else
echo "Release $TAG not found, creating..."
gh release create "$TAG" "$ZIP" --title "$TAG" --notes "Automated release created by CI for $TAG."
fi
env:
GH_TOKEN: ${{ github.token }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
/.parcel-cache/
/dist/
/node_modules/
/src/manifest.json
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ Greatly contributed by jazzzz. Thanks!
+ [Chrome webstore](https://chrome.google.com/webstore/detail/openswitchmaps/cfkddjlocfecchnemnnmmpdjcohgmkij)
+ [Firefox addon center](https://addons.mozilla.org/firefox/addon/openswitchmaps/)
### from source code
This extention uses Node.js
This extension uses Node.js
1. Install Node.js
1. Install the dependencies: npm install
1. Build the extension: npm run build
1. The extension is built in the `dist` directory
1. Install the dependencies: `npm install`
1. Build the extension: `TARGET=firefox npm run build` (or `TARGET=chrome npm run build`)
1. The extension is built in the `dist/firefox` directory
1. Add to your Chrome/Firefox

## How to use
Expand Down
Loading