Repository navigation
80 lines (68 loc) · 2.58 KB
/
Copy pathrelease.yml
File metadata and controls
80 lines (68 loc) · 2.58 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
name: Release
# Publishes the version in package.json to npm when a matching v* tag is
# pushed. npm proves this workflow's identity with trusted publishing (OIDC),
# so no token is stored. Until trusted publishing is set up for the package,
# an NPM_TOKEN secret is used instead.
on:
push:
tags: ["v*"]
permissions:
contents: write
id-token: write
concurrency:
group: release-${{ github.ref_name }}
cancel-in-progress: false
jobs:
release:
runs-on: ubuntu-latest
env:
TAG: ${{ github.ref_name }}
steps:
- uses: actions/checkout@v5
- uses: actions/setup-node@v5
with:
node-version: 24
registry-url: https://registry.npmjs.org
- name: Check that the tag matches package.json
run: |
version=$(node -p "require('./package.json').version")
if [ "v$version" != "$TAG" ]; then
echo "::error::Tag $TAG does not match package.json version $version"
exit 1
fi
echo "VERSION=$version" >> "$GITHUB_ENV"
- name: Install, check and test
run: |
npm ci
npm run check
npm test
# npm pack runs the build through prepack. The same tarball is tested and then published.
- name: Pack and run the packed CLI
run: |
npm pack
mkdir -p /tmp/dailydev-smoke
npm install --prefix /tmp/dailydev-smoke "./devopsdaily-dailydev-cli-$VERSION.tgz"
/tmp/dailydev-smoke/node_modules/.bin/dailydev --version | grep -qx "$VERSION"
- name: Update npm for trusted publishing
run: npm install -g npm@^11.5.1
- name: Publish to npm
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: |
if npm view "@devopsdaily/dailydev-cli@$VERSION" version > /dev/null 2>&1; then
echo "@devopsdaily/dailydev-cli@$VERSION is already on npm, skipping"
else
npm publish "./devopsdaily-dailydev-cli-$VERSION.tgz" --provenance --access public
fi
- name: Create the GitHub release
env:
GH_TOKEN: ${{ github.token }}
run: |
awk -v v="$VERSION" '
index($0, "## [" v "]") == 1 { found = 1; next }
/^## \[/ { if (found) exit }
found { print }
' CHANGELOG.md > release-notes.md
echo "" >> release-notes.md
echo "Install with \`npm install -g @devopsdaily/dailydev-cli@$VERSION\`." >> release-notes.md
gh release view "$TAG" > /dev/null 2>&1 || gh release create "$TAG" --title "$TAG" --notes-file release-notes.md --verify-tag