Skip to content

Release

Release #12

Workflow file for this run

name: Release
on:
push:
tags:
- 'v*'
permissions:
contents: write
packages: write
jobs:
update-version:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.get_version.outputs.version }}
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Get version from tag
id: get_version
run: |
VERSION=${GITHUB_REF#refs/tags/v}
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "Version: $VERSION"
goreleaser:
needs: update-version
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '>=1.22.0'
cache: true
- name: Update version in main.go
run: |
VERSION=${{ needs.update-version.outputs.version }}
BUILD_DATE=$(date +%Y-%m-%d)
sed -i "s/Version = \".*\"/Version = \"$VERSION\"/" main.go
sed -i "s/BuildDate = \".*\"/BuildDate = \"$BUILD_DATE\"/" main.go
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v4
with:
distribution: goreleaser
version: latest
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAP_GITHUB_TOKEN: ${{ secrets.TAP_GITHUB_TOKEN }}
npm-publish:
needs: [update-version, goreleaser]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '18'
registry-url: 'https://registry.npmjs.org'
- name: Update package.json version
run: |
VERSION=${{ needs.update-version.outputs.version }}
# Use jq to update version without npm version command
jq ".version = \"$VERSION\"" package.json > package.json.tmp
mv package.json.tmp package.json
- name: Install dependencies
run: npm ci || npm install
- name: Publish to NPM
run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}