Repository navigation
89 lines (81 loc) · 2.89 KB
/
Copy pathrelease.yml
File metadata and controls
89 lines (81 loc) · 2.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
name: Release
on:
push:
tags:
- "v*"
workflow_dispatch:
inputs:
tag:
description: "Existing tag to publish npm for (e.g. v0.1.3). Leave empty for a full release from a tag push."
required: false
type: string
npm_only:
description: "Only publish npm (skip GoReleaser)"
required: false
type: boolean
default: true
permissions:
contents: write
id-token: write
jobs:
goreleaser:
if: github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && !inputs.npm_only)
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v7
with:
fetch-depth: 0
- uses: actions/setup-go@v7
with:
go-version-file: go.mod
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v7
with:
distribution: goreleaser
version: "~> v2"
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
HOMEBREW_TAP_TOKEN: ${{ secrets.HOMEBREW_TAP_TOKEN || secrets.PACKAGING_TOKEN }}
SCOOP_TOKEN: ${{ secrets.SCOOP_TOKEN || secrets.PACKAGING_TOKEN }}
npm:
needs: goreleaser
if: |
always() && (
(github.event_name == 'push' && needs.goreleaser.result == 'success') ||
(github.event_name == 'workflow_dispatch' && (inputs.npm_only || needs.goreleaser.result == 'success'))
)
runs-on: ubuntu-24.04
defaults:
run:
working-directory: packaging/npm
steps:
- uses: actions/checkout@v7
with:
ref: ${{ inputs.tag || github.ref }}
- uses: actions/setup-node@v7
with:
node-version: "22.14"
# npm automation token (repo secret NPM_TOKEN). Same path as manual `npm publish` from packaging/npm.
- name: Publish npm package
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
VER: ${{ inputs.tag || github.ref_name }}
run: |
set -euo pipefail
if [ -z "${NODE_AUTH_TOKEN:-}" ]; then
echo "NPM_TOKEN not set — skipping npm publish (publish locally from packaging/npm if needed)." >&2
exit 0
fi
VER="${VER#v}"
if ! [[ "$VER" =~ ^[0-9]+\.[0-9]+\.[0-9]+ ]]; then
echo "Refusing to publish with version '$VER' (expected semver from tag)." >&2
exit 1
fi
node -e "const fs=require('fs'); const p=JSON.parse(fs.readFileSync('package.json','utf8')); p.version=process.env.VER; fs.writeFileSync('package.json', JSON.stringify(p,null,2)+'\n')"
echo "//registry.npmjs.org/:_authToken=${NODE_AUTH_TOKEN}" > .npmrc
if ! npm publish --access public; then
echo "npm publish failed (org scope / token). GoReleaser + Homebrew already published the binary." >&2
exit 0
fi
npm view "@devrecated/autodevelop@${VER}" version