Skip to content

Release

Release #11

Workflow file for this run

name: Release
run-name: >-
${{ inputs.dry_run && 'Release dry-run' || 'Release' }}
on:
workflow_dispatch:
inputs:
version:
description: "Release version to prepare, for example 1.2.3 or v1.2.3"
required: true
type: string
dry_run:
description: "Build and validate artifacts without publishing a GitHub Release or npm packages"
required: true
default: true
type: boolean
resume_existing_npm:
description: "Resume npm publish by skipping already-published matching package versions"
required: true
default: false
type: boolean
permissions:
contents: read
concurrency:
group: release-${{ github.ref }}
cancel-in-progress: false
jobs:
validate_dispatch:
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 0
ref: ${{ github.sha }}
- name: Validate release dispatch
env:
VERSION_INPUT: ${{ inputs.version }}
DRY_RUN: ${{ inputs.dry_run }}
RESUME_EXISTING_NPM: ${{ inputs.resume_existing_npm }}
run: node .github/scripts/release-workflow.js assert-dispatch-checkout
tag_and_dispatch:
needs: validate_dispatch
if: >-
${{
!inputs.dry_run &&
!inputs.resume_existing_npm &&
github.ref == 'refs/heads/main'
}}
runs-on: ubuntu-latest
permissions:
actions: write
contents: write
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 0
ref: ${{ github.sha }}
- name: Create tag and dispatch release run
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
VERSION_INPUT: ${{ inputs.version }}
DRY_RUN: ${{ inputs.dry_run }}
RESUME_EXISTING_NPM: ${{ inputs.resume_existing_npm }}
run: node .github/scripts/release-workflow.js tag-and-dispatch
dry-run:
needs: validate_dispatch
if: ${{ inputs.dry_run }}
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 0
ref: ${{ github.sha }}
- name: Assert checkout ref
env:
VERSION_INPUT: ${{ inputs.version }}
DRY_RUN: ${{ inputs.dry_run }}
RESUME_EXISTING_NPM: ${{ inputs.resume_existing_npm }}
run: node .github/scripts/release-workflow.js assert-dispatch-checkout
- uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0
with:
go-version-file: go.mod
- uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
node-version: 24
registry-url: https://registry.npmjs.org
scope: "@customerio"
- name: Test
run: go test ./...
- uses: goreleaser/goreleaser-action@1a80836c5c9d9e5755a25cb59ec6f45a3b5f41a8 # v7.2.1
with:
version: "~> v2"
args: release --clean --snapshot --skip=publish
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: goreleaser-dist
path: dist/
- name: Prepare npm packages
env:
VERSION: ${{ inputs.version }}
run: node .github/scripts/prepare-npm-packages.js --pack-dry-run
- name: Validate package metadata
env:
VERSION: ${{ inputs.version }}
run: node .github/scripts/publish-npm.js --check
- name: Validate npm publish command
env:
VERSION: ${{ inputs.version }}
run: node .github/scripts/publish-npm.js --dry-run
github_release:
needs: validate_dispatch
if: >-
${{
always() &&
needs.validate_dispatch.result == 'success' &&
!inputs.dry_run &&
!inputs.resume_existing_npm &&
startsWith(github.ref, 'refs/tags/')
}}
runs-on: ubuntu-latest
environment: release
permissions:
contents: write
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 0
ref: ${{ github.sha }}
- name: Assert checkout and tag ref
env:
VERSION_INPUT: ${{ inputs.version }}
DRY_RUN: ${{ inputs.dry_run }}
RESUME_EXISTING_NPM: ${{ inputs.resume_existing_npm }}
run: node .github/scripts/release-workflow.js assert-tag-run
- uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0
with:
go-version-file: go.mod
- name: Test
run: go test ./...
- uses: goreleaser/goreleaser-action@1a80836c5c9d9e5755a25cb59ec6f45a3b5f41a8 # v7.2.1
with:
version: "~> v2"
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: goreleaser-dist
path: dist/
npm_resume_build:
needs: validate_dispatch
if: ${{ !inputs.dry_run && inputs.resume_existing_npm }}
runs-on: ubuntu-latest
environment: release
permissions:
contents: read
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 0
ref: ${{ github.sha }}
- name: Assert checkout and tag ref
env:
VERSION_INPUT: ${{ inputs.version }}
DRY_RUN: ${{ inputs.dry_run }}
RESUME_EXISTING_NPM: ${{ inputs.resume_existing_npm }}
run: node .github/scripts/release-workflow.js assert-tag-run
- name: Assert GitHub Release already exists
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
VERSION_INPUT: ${{ inputs.version }}
DRY_RUN: ${{ inputs.dry_run }}
RESUME_EXISTING_NPM: ${{ inputs.resume_existing_npm }}
run: node .github/scripts/release-workflow.js assert-existing-release
- uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0
with:
go-version-file: go.mod
- name: Test
run: go test ./...
- uses: goreleaser/goreleaser-action@1a80836c5c9d9e5755a25cb59ec6f45a3b5f41a8 # v7.2.1
with:
version: "~> v2"
args: release --clean --skip=publish
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: goreleaser-dist
path: dist/
npm_publish:
needs:
- github_release
- npm_resume_build
if: >-
${{
always() &&
!inputs.dry_run &&
(
needs.github_release.result == 'success' ||
needs.npm_resume_build.result == 'success'
)
}}
runs-on: ubuntu-latest
environment: release
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 0
ref: ${{ github.sha }}
- name: Assert checkout and tag ref
env:
VERSION_INPUT: ${{ inputs.version }}
DRY_RUN: ${{ inputs.dry_run }}
RESUME_EXISTING_NPM: ${{ inputs.resume_existing_npm }}
run: node .github/scripts/release-workflow.js assert-tag-run
- uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
node-version: 24
registry-url: https://registry.npmjs.org
scope: "@customerio"
- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: goreleaser-dist
path: dist/
- name: Prepare npm packages
env:
VERSION: ${{ inputs.version }}
run: node .github/scripts/prepare-npm-packages.js
- name: Publish npm packages
env:
VERSION: ${{ inputs.version }}
RESUME_EXISTING_NPM: ${{ inputs.resume_existing_npm }}
run: |
args=()
if [[ "$RESUME_EXISTING_NPM" == "true" ]]; then
args+=(--resume-existing)
fi
node .github/scripts/publish-npm.js "${args[@]}"