Skip to content
Merged
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
3 changes: 2 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"sourceType": "module"
},
"rules": {
"no-undef": "off"
"no-undef": "off",
"no-extra-semi": "off"
}
}
1 change: 1 addition & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ko_fi: cssnr
6 changes: 6 additions & 0 deletions .github/actionlint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
paths:
.github/workflows/**/*.{yml,yaml}:
ignore:
- '"inputs" section is alias node but mapping node is expected'
- '"paths" section must be sequence node but got alias node with "" tag'
- '"paths-ignore" section must be sequence node but got alias node with "" tag'
155 changes: 33 additions & 122 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -1,149 +1,60 @@
name: "Build"

on:
workflow_call:
inputs: &inputs
version:
description: "Build Version"
type: string
default: "0.0.1"
workflow_dispatch:
release:
types: [published]

env:
SRC_DIR: src
CHROME_ID: medimbembaeldnglneiipkenpagjfcdj
MOZILLA_ID: web-tools-extension@cssnr.com
MOZILLA_CHANNEL: unlisted
inputs: *inputs

jobs:
build:
name: "Build"
runs-on: ubuntu-latest
timeout-minutes: 5

outputs:
version: ${{ steps.manifest.outputs.version }}
package_name: ${{ steps.manifest.outputs.package_name }}
permissions:
contents: write

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

- name: "Parse Manifest"
id: manifest
run: |-
echo "version=$(jq '.version' < manifest.json | tr -d '"')" >> "$GITHUB_OUTPUT"
export name="$(jq '.name' < manifest.json | tr -d '"' | tr '[:upper:]' '[:lower:]')"
echo "package_name=${name// /_}" >> "$GITHUB_OUTPUT"

- name: "Release Version Check"
if: ${{ github.event_name == 'release' }}
run: |-
echo ${{ github.ref_name }}
echo ${{ steps.manifest.outputs.version }}
if [ "${{ github.ref_name }}" != "${{ steps.manifest.outputs.version }}" ];then
echo "Manifest Version ${version} does not match release tag ${{ github.ref_name }}"
exit 1
fi

- name: "Setup Node"
uses: actions/setup-node@v4
with:
node-version: 20

- name: "Build All"
run: |-
npm install
npm run build
uses: actions/checkout@v6

- name: "Upload to Actions"
uses: actions/upload-artifact@v4
- name: "Setup Node 24"
uses: actions/setup-node@v6
with:
name: artifacts
path: web-ext-artifacts/
node-version: 24

- name: "Upload to Release"
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: web-ext-artifacts/*
tag: ${{ github.ref }}
overwrite: true
file_glob: true

publish-mozilla:
name: "Publish Mozilla"
runs-on: ubuntu-latest
timeout-minutes: 30
needs: [build]
if: ${{ github.event_name == 'release' }}

steps:
- name: "Download Artifacts"
uses: actions/download-artifact@v4
with:
name: artifacts
- name: "Install"
run: |
npm ci

- name: "Generate Release Notes"
env:
NOTES: "Full Release Notes: ${{ github.server_url }}/${{ github.repository }}/releases/tag/${{ github.ref }}"
uses: jsdaniell/create-json@v1.2.3
- name: "Update Manifest Version"
if: ${{ github.event_name == 'release' }}
uses: cssnr/update-json-value-action@v2
with:
name: "amo-metadata.json"
json: '{"version": {"release_notes": {"en-US": "${{ env.NOTES }}"}}}'
values: ${{ inputs.version }}

- name: "Sign Mozilla Addon"
run: |-
unzip *firefox* -d src
npx web-ext sign --api-key="${{ secrets.FIREFOX_API_KEY }}" \
--api-secret="${{ secrets.FIREFOX_API_SECRET }}" \
--source-dir="${{ env.SRC_DIR }}" \
--channel="${{ env.MOZILLA_CHANNEL }}" \
--amo-metadata="amo-metadata.json"
- name: "Debug Manifest"
continue-on-error: true
run: |
cat -n manifest.json

- name: "Rename Signed Artifact"
working-directory: web-ext-artifacts
run: |-
ls -l .
mv *.xpi "${{ needs.build.outputs.package_name }}-firefox.xpi"
ls -l .
- name: "Build"
run: |
npm run build

- name: "Upload to Actions"
uses: actions/upload-artifact@v4
uses: actions/upload-artifact@v6
with:
name: signed
path: web-ext-artifacts/
name: artifacts
path: web-ext-artifacts

- name: "Upload to Release"
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: web-ext-artifacts/*
tag: ${{ github.ref }}
overwrite: true
file_glob: true

update-mozilla:
name: "Update Mozilla"
runs-on: ubuntu-latest
timeout-minutes: 5
needs: [publish-mozilla]
if: ${{ github.event_name == 'release' }}

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

- name: "Mozilla Addon Update"
uses: cssnr/mozilla-addon-update-action@master
with:
url: "https://github.com/cssnr/text-formatter/releases/download/{version}/text_formatter-firefox.xpi"
addon_id: ${{ env.MOZILLA_ID }}

- name: "Commit files"
run: |
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git commit -a -m "Update update.json"

- name: "Push changes"
uses: ad-m/github-push-action@master
if: ${{ github.event_name == 'release' }}
uses: cssnr/upload-release-action@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: master
globs: web-ext-artifacts/*
34 changes: 34 additions & 0 deletions .github/workflows/draft.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: "Draft Release"

on:
workflow_dispatch:
push:
branches: ["master"]

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
draft:
name: "Draft Release"
runs-on: ubuntu-latest
timeout-minutes: 5

permissions:
contents: write

steps:
- name: "Checkout"
uses: actions/checkout@v6

- name: "Draft Release Action"
id: draft
uses: cssnr/draft-release-action@master
with:
semver: patch
prerelease: false

- name: "Process Release Draft URL"
run: |
echo "url: ${{ steps.draft.outputs.url }}"
52 changes: 52 additions & 0 deletions .github/workflows/labeler.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: "PR Labeler"

on:
pull_request_target:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
labeler:
name: "Labeler"
runs-on: ubuntu-latest
timeout-minutes: 5

permissions:
pull-requests: write
issues: write

steps:
- name: "Checkout Configs"
uses: actions/checkout@v6
with:
repository: cssnr/configs
ref: master
path: .configs
sparse-checkout-cone-mode: false
sparse-checkout: |
labels/**

- name: "Debug"
continue-on-error: true
run: |
echo "::group::labels.yaml"
cat .configs/labels/labels.yaml
echo "::endgroup::"

echo "::group::labeler.yaml"
cat .configs/labels/labeler.yaml
echo "::endgroup::"

- name: "Label Creator"
continue-on-error: true
uses: cssnr/label-creator-action@latest
with:
file: .configs/labels/labels.yaml

- name: "Labeler"
uses: actions/labeler@v6
with:
sync-labels: true
configuration-path: .configs/labels/labeler.yaml
55 changes: 55 additions & 0 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: "Lint"

on:
workflow_dispatch:
push:
branches: [master]
pull_request:
branches: [master]

jobs:
lint:
name: "Lint"
runs-on: ubuntu-latest
timeout-minutes: 5
if: ${{ !contains(github.event.head_commit.message, '#nolint') }}

steps:
- name: "Checkout"
uses: actions/checkout@v6

- name: "Setup Node 24"
uses: actions/setup-node@v6
with:
node-version: 24

- name: "Install"
id: install
run: |
npm ci

- name: "eslint"
if: ${{ !cancelled() }}
run: |
npm run lint

- name: "prettier"
if: ${{ !cancelled() }}
run: |
npm run prettier:check

- name: "yamllint"
if: ${{ !cancelled() }}
env:
CONFIG: .github/yamllint.yaml
run: |
echo "::group::List Files"
yamllint -c "${{ env.CONFIG }}" --list-files .
echo "::endgroup::"
yamllint -c "${{ env.CONFIG }}" .

- name: "actionlint"
if: ${{ !cancelled() }}
uses: cssnr/actionlint-action@v1
with:
shellcheck_opts: -e SC2129
Loading
Loading