This repository has been archived by the owner on Jul 23, 2024. It is now read-only.
Merge pull request #108 from invopop/gobl-0.78 #124
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# Automatically tag a merge with master, or build a new image from the tag. | |
# | |
# Secrets required: | |
# * `GOOGLE_APPLICATION_CREDENTIALS` - for goreleaser blob publish | |
# | |
name: Release | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
tag-build-publish: | |
name: Tag | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: "0" # make sure we get all commits! | |
- name: Authorize Google Account | |
id: "auth" | |
uses: "google-github-actions/auth@v0" | |
with: | |
credentials_json: "${{ secrets.GOOGLE_APPLICATION_CREDENTIALS }}" | |
- name: Bump version and push tag | |
id: bump | |
uses: anothrNick/github-tag-action@1.36.0 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
RELEASE_BRANCHES: main | |
WITH_V: true | |
- name: Set up Go | |
uses: actions/setup-go@v2 | |
with: | |
go-version: 1.21 | |
# Ensure we have a wasm_exec.js for the current version of Go | |
- name: Copy Go WASM Exec | |
if: ${{ steps.bump.new_tag == steps.bump.tag }} | |
run: cp "$(go env GOROOT)/misc/wasm/wasm_exec.js" ./gobl-worker/src | |
- name: Run GoReleaser | |
uses: goreleaser/goreleaser-action@v2 | |
with: | |
# either 'goreleaser' (default) or 'goreleaser-pro' | |
distribution: goreleaser | |
version: latest | |
args: release --rm-dist | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
# Your GoReleaser Pro key, if you are using the 'goreleaser-pro' distribution | |
# GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }} | |
# Following actions are to release a new version of gobl-worker to NPM | |
# using the new wasm version in the CDN. | |
- name: Install Node.js | |
uses: actions/setup-node@v3 | |
if: ${{ steps.bump.new_tag == steps.bump.tag }} | |
with: | |
node-version: 16.x | |
cache: "npm" | |
cache-dependency-path: "./gobl-worker/package-lock.json" | |
- name: Run npm install | |
if: ${{ steps.bump.new_tag == steps.bump.tag }} | |
working-directory: ./gobl-worker | |
run: npm install | |
- name: Update gobl-worker version | |
if: ${{ steps.bump.new_tag == steps.bump.tag }} | |
working-directory: ./gobl-worker | |
run: npm version --no-git-tag-version ${{ steps.bump.outputs.new_tag }} | |
- name: Build gobl-worker | |
if: ${{ steps.bump.new_tag == steps.bump.tag }} | |
working-directory: ./gobl-worker | |
run: npm run build | |
- name: Publish gobl-worker to NPM registry | |
if: ${{ steps.bump.new_tag == steps.bump.tag }} | |
uses: JS-DevTools/npm-publish@v1 | |
with: | |
token: ${{ secrets.NPM_TOKEN }} | |
package: ./gobl-worker/package.json | |
access: public |