Skip to content

chore: post-release cleanup (workflow#767 followup) (#19) #56

chore: post-release cleanup (workflow#767 followup) (#19)

chore: post-release cleanup (workflow#767 followup) (#19) #56

Workflow file for this run

name: Release
on:
push:
tags:
- 'v*'
env:
GONOSUMCHECK: github.com/GoCodeAlone/*
GONOSUMDB: github.com/GoCodeAlone/*
GOPRIVATE: github.com/GoCodeAlone/*
jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.26'
- name: Configure git for private modules
run: git config --global url."https://${{ secrets.RELEASES_TOKEN }}@github.com/".insteadOf "https://github.com/"
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v7
with:
distribution: goreleaser
version: '~> v2'
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.RELEASES_TOKEN }}
publish-release:
if: startsWith(github.ref, 'refs/tags/v')
needs: [release]
permissions:
contents: write
runs-on: ubuntu-latest
steps:
- name: Publish GitHub release
uses: actions/github-script@v7
with:
github-token: ${{ github.token }}
script: |
const tag = process.env.GITHUB_REF_NAME;
const { owner, repo } = context.repo;
let release;
// listReleases returns drafts; getReleaseByTag 404s on drafts. GoReleaser
// creates releases as draft; this step flips them to non-draft post-publish.
const { data: releases } = await github.rest.repos.listReleases({ owner, repo, per_page: 100 });
release = releases.find(r => r.tag_name === tag);
if (!release) {
core.setFailed(`No GitHub release found for ${tag} in repo listing (latest 100); ensure GoReleaser created it before publishing.`);
return;
}
if (release.draft) {
await github.rest.repos.updateRelease({
owner,
repo,
release_id: release.id,
draft: false,
});
}
notify-registry:
if: startsWith(github.ref, 'refs/tags/v')
needs: [publish-release]
runs-on: ubuntu-latest
steps:
- name: Notify workflow-registry
if: env.GH_TOKEN != ''
uses: peter-evans/repository-dispatch@v3
with:
token: ${{ secrets.REGISTRY_PAT }}
repository: GoCodeAlone/workflow-registry
event-type: plugin-release
client-payload: >-
{"plugin": "${{ github.repository }}", "tag": "${{ github.ref_name }}"}
env:
GH_TOKEN: ${{ secrets.REGISTRY_PAT }}
continue-on-error: true