-
Notifications
You must be signed in to change notification settings - Fork 0
138 lines (128 loc) · 4.41 KB
/
Copy pathnpm_publish.yml
File metadata and controls
138 lines (128 loc) · 4.41 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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
name: Publish
run-name: Publish ${{ inputs.semver-bump }} bump
on:
workflow_dispatch:
inputs:
semver-bump:
description: Semver bump release type
required: true
type: choice
default: prerelease
options:
- major
- minor
- patch
- prerelease
concurrency: publish
jobs:
check-build-params:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 24
- name: changelog entries
if: ${{ inputs.semver-bump != 'prerelease' }}
run: npx -y @eighty4/changelog check
verify:
uses: ./.github/workflows/ci_verify.yml
needs: check-build-params
create-git-tag:
runs-on: ubuntu-latest
needs: verify
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
- uses: actions/setup-node@v4
with:
node-version: 24
- id: bump
run: |
GIT_TAG=$(npm version ${{ inputs.semver-bump }} --no-git-tag-version)
echo "version=${GIT_TAG:1}" >> "$GITHUB_OUTPUT"
echo "tag=$GIT_TAG" >> "$GITHUB_OUTPUT"
- if: inputs.semver-bump != 'prerelease'
env:
VERSION: ${{ steps.bump.outputs.version }}
run: npx -y @eighty4/changelog rollover "v$VERSION"
- id: push
env:
GIT_TAG: ${{ steps.bump.outputs.tag }}
NPM_TAG: ${{ inputs.semver-bump == 'prerelease' && 'next' || 'latest' }}
run: |
git config --global user.name "Adam McKee"
git config --global user.email "adam.be.g84d@gmail.com"
git add package.json CHANGELOG.md
git commit -m "publishing $GIT_TAG as @$NPM_TAG"
git tag $GIT_TAG
git push --atomic origin main $GIT_TAG
outputs:
tag: ${{ steps.bump.outputs.tag }}
version: ${{ steps.bump.outputs.version }}
npm-publish:
needs: create-git-tag
runs-on: ubuntu-latest
permissions:
id-token: write
steps:
- uses: actions/checkout@v4
with:
fetch-tags: true
ref: ${{ needs.create-git-tag.outputs.tag }}
- uses: pnpm/action-setup@v4
- uses: actions/setup-node@v4
with:
node-version: 24
registry-url: https://registry.npmjs.org
- run: pnpm i
- run: pnpm run build
- name: publish
env:
NPM_TAG: ${{ inputs.semver-bump == 'prerelease' && 'next' || 'latest' }}
run: pnpm publish --access public --tag $NPM_TAG --no-git-checks
create-release-notes:
runs-on: ubuntu-latest
needs: [create-git-tag, npm-publish]
steps:
- uses: actions/checkout@v4
with:
fetch-tags: true
ref: ${{ needs.create-git-tag.outputs.tag }}
- uses: actions/setup-node@v4
with:
node-version: 24
- id: gen
env:
CHANGELOG_TAG: ${{ inputs.semver-bump == 'prerelease' && 'Unreleased' || needs.create-git-tag.outputs.tag }}
GIT_TAG: ${{ needs.create-git-tag.outputs.tag }}
NPM_TAG: ${{ inputs.semver-bump == 'prerelease' && 'next' || 'latest' }}
run: |
PKG_NAME=$(cat package.json | jq -r ".name")
VERSION=${GIT_TAG:1}
echo "#### Published to npm as [$PKG_NAME](https://www.npmjs.com/package/$PKG_NAME/v/$VERSION)" >> release_notes.md
echo >> release_notes.md
echo "\`\`\`npm i -g $PKG_NAME@$NPM_TAG\`\`\`" >> release_notes.md
echo >> release_notes.md
echo "## Release notes" >> release_notes.md
echo >> release_notes.md
npx -y @eighty4/changelog get "$CHANGELOG_TAG" >> release_notes.md
echo >> release_notes.md
RELEASE_NOTES=$(cat release_notes.md | base64 -w 0)
echo "notes=$RELEASE_NOTES" >> "$GITHUB_OUTPUT"
outputs:
notes: ${{ steps.gen.outputs.notes }}
create-gh-release:
uses: ./.github/workflows/gh_release.yml
needs: [create-git-tag, create-release-notes, npm-publish]
permissions:
contents: write
secrets: inherit
with:
title: '${{ needs.create-git-tag.outputs.tag }}'
release_notes: ${{ needs.create-release-notes.outputs.notes }}
prerelease: ${{ inputs.semver-bump == 'prerelease' && 'true' || 'false' }}
latest: ${{ inputs.semver-bump == 'prerelease' && 'false' || 'true' }}
tag: ${{ needs.create-git-tag.outputs.tag }}