Skip to content

Merge pull request #445 from invopop/release-0.207.0 #196

Merge pull request #445 from invopop/release-0.207.0

Merge pull request #445 from invopop/release-0.207.0 #196

Workflow file for this run

#
# Automatically tag a merge with master, or build a new image from the tag.
#
# Secrets required:
# * `GITHUB_TOKEN` - A GitHub token with access to the repository.
# * `AWS_ACCESS_KEY_ID` - An AWS access key with write access to the CDN bucket.
# * `AWS_SECRET_ACCESS_KEY` - The secret for the AWS access key
# * `NPM_TOKEN` - An NPM token with access to the package.
#
name: Release
on:
push:
branches:
- main
paths:
- "version.go"
jobs:
tag-build-publish:
name: Tag & Release
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: "0" # make sure we get all commits!
- name: Read current version
run: |
grep 'const VERSION' version.go | sed -e 's/const VERSION Version = "\(v[^"]*\)"/GOBL_VERSION=\1/' >> $GITHUB_ENV
- name: Bump version and push tag
id: bump
uses: anothrNick/[email protected]
env:
CUSTOM_TAG: ${{ env.GOBL_VERSION }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
RELEASE_BRANCHES: main
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: "go.mod"
# 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" ./wasm/worker/src
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v6
with:
# either 'goreleaser' (default) or 'goreleaser-pro'
distribution: goreleaser
version: latest
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
# 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: "./wasm/worker/package-lock.json"
- name: Run npm install
if: ${{ steps.bump.new_tag == steps.bump.tag }}
working-directory: ./wasm/worker
run: npm install
- name: Update gobl-worker version
if: ${{ steps.bump.new_tag == steps.bump.tag }}
working-directory: ./wasm/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: ./wasm/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: ./wasm/worker/package.json
access: public