Skip to content

Commit

Permalink
ci: build extension and semantic release
Browse files Browse the repository at this point in the history
  • Loading branch information
aeddi committed Oct 15, 2024
1 parent 66f290e commit 44e2493
Show file tree
Hide file tree
Showing 3 changed files with 111 additions and 2 deletions.
71 changes: 71 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: Build

on:
push:
branches:
- main
pull_request:

jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: write # Semantic Action requires this to create tags
steps:
- name: Checkout
uses: actions/checkout@v4

# Semantic Action requires nodejs but won't run in checkout dir
- name: Copy .tool-versions to home
run: cp .tool-versions $HOME

- name: Install node using asdf
uses: asdf-vm/actions/install@v3

- name: Get npm cache path
id: npm-cache-dir
shell: bash
run: echo "dir=$(npm config get cache)" >> ${GITHUB_OUTPUT}

- name: Cache npm cache directory
uses: actions/cache@v4
with:
path: ${{ steps.npm-cache-dir.outputs.dir }}
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Build extension for all browsers
run: BROWSER=all make build

- name: Semantic Release (Dry Run)
if: github.event_name == 'pull_request'
uses: cycjimmy/semantic-release-action@v4
with:
dry_run: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Semantic Release
if: github.event_name != 'pull_request'
uses: cycjimmy/semantic-release-action@v4
id: semantic
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Archive browser extensions
if: steps.semantic.outputs.new_release_published == 'true' && github.event_name != 'pull_request'
run: |
mkdir -p "${GITHUB_WORKSPACE}/archives"
for browser in chrome edge firefox; do
cd "${GITHUB_WORKSPACE}/dist/$browser"
zip -r "${GITHUB_WORKSPACE}/archives/$browser-gno-sidecar-${{ steps.semantic.outputs.new_release_version }}.zip" *
done
- name: Upload extensions to Github Release
if: steps.semantic.outputs.new_release_published == 'true' && github.event_name != 'pull_request'
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.semantic.outputs.new_release_git_tag }}
body: ${{ steps.semantic.outputs.new_release_notes }}
files: ${{ github.workspace }}/archives/*.zip
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"manifest_version": 3,
"version": "1.0",
"version": "1.0.0",
"name": "Gno Sidecar",
"description": "A browser extension for Gnoweb and more broadly Gno, providing a set of devtools, tweaks and experimentation.",
"author": "Gno R&D",
Expand Down
40 changes: 39 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "gno-sidecar",
"description": "A browser extension for Gnoweb and more broadly Gno, providing a set of devtools, tweaks and experimentation.",
"version": "1.0",
"version": "1.0.0",
"license": "Apache-2.0",
"author": {
"name": "Gno R&D",
Expand All @@ -27,11 +27,49 @@
"tailwindcss": "^3.4.1"
},
"devDependencies": {
"@semantic-release/git": "^10.0.1",
"@types/react": "^18.3.5",
"@types/react-dom": "^18.3.0",
"extension": "latest",
"node-polyfill-webpack-plugin": "^4.0.0",
"semantic-release-replace-plugin": "^1.2.7",
"typescript": "5.3.3"
},
"release": {
"plugins": [
"@semantic-release/commit-analyzer",
[
"semantic-release-replace-plugin",
{
"replacements": [
{
"files": [
"manifest.json"
],
"from": "\"version\": \".*\"",
"to": "\"version\": \"${nextRelease.version}\"",
"results": [
{
"file": "manifest.json",
"hasChanged": true,
"numMatches": 1,
"numReplacements": 1
}
],
"countMatches": true
}
]
}
],
[
"@semantic-release/git",
{
"assets": [
"manifest.json"
]
}
]
]
},
"private": true
}

0 comments on commit 44e2493

Please sign in to comment.