Skip to content

Add existing project adoption workflow #11

Add existing project adoption workflow

Add existing project adoption workflow #11

Workflow file for this run

name: Release
# Releases are cut by pushing a semver tag (e.g. v0.3.0). The tag is the version.
# GoReleaser publishes the GitHub release, cross-platform binaries, and the Homebrew
# cask; a follow-up step builds and publishes the @productize/cli npm wrapper.
on:
pull_request:
types:
- opened
- synchronize
branches:
- main
push:
tags:
- "v*"
workflow_dispatch:
inputs:
tag:
description: "Existing tag to (re)release, e.g. v0.3.0"
required: true
type: string
concurrency:
group: release-${{ github.ref }}
cancel-in-progress: false
env:
GO_VERSION: "1.26.1"
NODE_VERSION: "22"
PR_RELEASE_MODULE: github.com/productize/releasepr@v0.0.21
permissions:
contents: write
jobs:
dry-run:
name: Dry-Run Release Check
if: |
github.event_name == 'pull_request' &&
(startsWith(github.event.pull_request.title, 'ci(release): Release ') ||
startsWith(github.event.pull_request.title, 'release: Release '))
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
fetch-tags: true
- name: Prepare Go temporary directory
env:
GOTMPDIR: ${{ runner.temp }}/go-tmp
run: mkdir -p "$GOTMPDIR"
- uses: ./.github/actions/setup-go
with:
go-version: ${{ env.GO_VERSION }}
install-tools: "false"
- uses: ./.github/actions/setup-node
- uses: ./.github/actions/setup-release
with:
goreleaser-distribution: goreleaser
setup-docker: false
setup-docker-login: false
- name: Run Release PR dry-run
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_REPOSITORY: ${{ github.repository }}
GITHUB_REPOSITORY_OWNER: ${{ github.repository_owner }}
GITHUB_HEAD_REF: ${{ github.head_ref }}
GITHUB_ISSUE_NUMBER: ${{ github.event.pull_request.number }}
GOTMPDIR: ${{ runner.temp }}/go-tmp
run: go run "${{ env.PR_RELEASE_MODULE }}" dry-run --ci-output
release:
name: Release
if: github.event_name != 'pull_request'
runs-on: ubuntu-latest
timeout-minutes: 60
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
fetch-tags: true
ref: ${{ github.event.inputs.tag || github.ref }}
- name: Prepare Go temporary directory
env:
GOTMPDIR: ${{ runner.temp }}/go-tmp
run: mkdir -p "$GOTMPDIR"
- uses: ./.github/actions/setup-go
with:
go-version: ${{ env.GO_VERSION }}
install-tools: "true"
- uses: ./.github/actions/setup-node
- uses: ./.github/actions/setup-release
with:
goreleaser-distribution: goreleaser
setup-docker: false
setup-docker-login: false
- name: Resolve release version
id: release-version
run: |
REF="${{ github.event.inputs.tag || github.ref_name }}"
VERSION="${REF#v}"
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
echo "Releasing version $VERSION"
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v6
with:
distribution: goreleaser
version: ~> v2
args: >-
release --clean --skip=sign --skip=sbom
--release-header-tmpl=.goreleaser.release-header.md.tmpl
--release-footer-tmpl=.goreleaser.release-footer.md.tmpl
env:
GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }}
GOTMPDIR: ${{ runner.temp }}/go-tmp
- name: Build npm CLI package
run: >-
node npm/cli/prepare-package.mjs
--version "${{ steps.release-version.outputs.version }}"
--dist dist
--out dist/npm/@productize/cli
- name: Publish npm CLI package
run: npm publish dist/npm/@productize/cli --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}