diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..4eca2d3 --- /dev/null +++ b/.github/workflows/build.yml @@ -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 diff --git a/manifest.json b/manifest.json index 57776d6..5281ea2 100644 --- a/manifest.json +++ b/manifest.json @@ -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", diff --git a/package.json b/package.json index dd178d8..2c1c5fb 100644 --- a/package.json +++ b/package.json @@ -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", @@ -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 }