Skip to content

Commit c5dae5f

Browse files
added a workflow for build and release, renamed mozilla with firefox
1 parent 215fd0e commit c5dae5f

File tree

6 files changed

+83
-9
lines changed

6 files changed

+83
-9
lines changed

.github/workflows/main.yml

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
name: Build and Release
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
8+
permissions:
9+
contents: write
10+
11+
jobs:
12+
build:
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
# Step 1: Checkout the code
17+
- name: Checkout code
18+
uses: actions/checkout@v3
19+
20+
# Step 2: Set up Node.js using .nvmrc
21+
- name: Set up Node.js
22+
uses: actions/setup-node@v3
23+
with:
24+
node-version-file: .nvmrc
25+
26+
# Step 3: Install dependencies
27+
- name: Install dependencies
28+
run: npm install
29+
30+
# Step 4: Build the project
31+
- name: Build project
32+
run: npm run build
33+
34+
# Step 4.5: Extract version from package.json
35+
- name: Get Package Version
36+
id: pkg_version
37+
run: |
38+
VERSION=$(jq -r '.version' package.json)
39+
echo "VERSION=$VERSION" >> $GITHUB_ENV
40+
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
41+
42+
# Step 5: Create a GitHub Release
43+
- name: Create Release
44+
id: create_release
45+
uses: actions/create-release@v1
46+
env:
47+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
48+
with:
49+
tag_name: v${{ steps.pkg_version.outputs.VERSION }}
50+
release_name: Release v${{ steps.pkg_version.outputs.VERSION }}
51+
draft: false
52+
prerelease: false
53+
54+
# Step 6: Archive each folder within dist and upload each as a release asset
55+
- name: Archive and Upload Release Assets
56+
env:
57+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
58+
run: |
59+
UPLOAD_URL="${{ steps.create_release.outputs.upload_url }}"
60+
UPLOAD_URL="${UPLOAD_URL%\{*}"
61+
for folder in dist/*/; do
62+
folder=${folder%/} # Remove trailing slash
63+
zip_name="${folder##*/}.zip"
64+
echo "Zipping contents of $folder into $zip_name"
65+
pushd "$folder" > /dev/null
66+
zip -r "$GITHUB_WORKSPACE/$zip_name" ./*
67+
popd > /dev/null
68+
echo "Uploading $zip_name"
69+
curl -s --data-binary @"$GITHUB_WORKSPACE/$zip_name" \
70+
-H "Content-Type: application/zip" \
71+
-H "Authorization: token ${GITHUB_TOKEN}" \
72+
"$UPLOAD_URL?name=$(basename "$zip_name")"
73+
done

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
node_modules
2-
.vscode
2+
.vscode
3+
dist

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ npm run dev:chrome
123123

124124
B. For Gecko-based browsers like Firefox, Waterfox, Pale Moon, and others:
125125
```sh
126-
npm run dev:mozilla
126+
npm run dev:firefox
127127
```
128128

129129
#### II. For production:
@@ -137,7 +137,7 @@ To build the project for production, run:
137137

138138
2. For Gecko-based browsers:
139139
```sh
140-
npm run build:mozilla
140+
npm run build:firefox
141141
```
142142

143143
### Linting
@@ -162,7 +162,7 @@ To install the the compiled extension, for:
162162
- `about:debugging#/runtime/this-firefox`
163163
- etc.
164164
165-
and click on `Load Temporary Add-on…` then select `<scribe-pal folder>/dist/mozilla` folder.
165+
and click on `Load Temporary Add-on…` then select `<scribe-pal folder>/dist/firefox` folder.
166166
167167
## Usage
168168
File renamed without changes.

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@
88
"scripts": {
99
"typecheck": "tsc --noEmit",
1010
"dev:chrome": "tsc --noEmit && webpack --mode development --env browser=chrome --config webpack.config.mjs",
11-
"dev:mozilla": "tsc --noEmit && webpack --mode development --env browser=mozilla --config webpack.config.mjs",
11+
"dev:firefox": "tsc --noEmit && webpack --mode development --env browser=firefox --config webpack.config.mjs",
1212
"build:chrome": "tsc --noEmit && webpack --mode production --env browser=chrome --config webpack.config.mjs",
13-
"build:mozilla": "tsc --noEmit && webpack --mode production --env browser=mozilla --config webpack.config.mjs",
13+
"build:firefox": "tsc --noEmit && webpack --mode production --env browser=firefox --config webpack.config.mjs",
1414
"lint": "eslint .",
15-
"dev": "npm run lint && concurrently \"npm run dev:chrome\" \"npm run dev:mozilla\"",
16-
"build": "npm run lint && concurrently \"npm run build:chrome\" \"npm run build:mozilla\""
15+
"dev": "npm run lint && concurrently \"npm run dev:chrome\" \"npm run dev:firefox\"",
16+
"build": "npm run lint && concurrently \"npm run build:chrome\" \"npm run build:firefox\""
1717
},
1818
"dependencies": {
1919
"crypto-browserify": "^3.12.1",

webpack.config.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export default (env) => {
1111
const browser = env.browser || "chrome";
1212
const updatedBaseConfig = baseConfig(
1313
browser,
14-
browser === "chrome" ? "manifest.json" : "mozilla.manifest.json"
14+
browser === "chrome" ? "manifest.json" : "firefox.manifest.json"
1515
);
1616

1717
if (browser !== "chrome") {

0 commit comments

Comments
 (0)