-
Notifications
You must be signed in to change notification settings - Fork 0
112 lines (98 loc) · 3.11 KB
/
release.yml
File metadata and controls
112 lines (98 loc) · 3.11 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
---
name: Release
run-name: Release ${{ github.event.inputs.tag || '0.0.0-test' }}
on:
# For testing - remove before merging
push:
branches:
- improvement/CLDSRVCLT-7
workflow_dispatch:
inputs:
tag:
description: 'Tag to be released (e.g., 1.0.0)'
required: true
env:
# Use input tag for workflow_dispatch, or test tag for push events
RELEASE_TAG: ${{ github.event.inputs.tag || '0.0.0-test' }}
jobs:
check:
name: Preliminary checks
runs-on: ubuntu-latest
# Only run check for manual workflow_dispatch (not for push events)
if: github.event_name == 'workflow_dispatch'
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Ensure version matches tag
run: |
PACKAGE_VERSION=$(node -p "require('./package.json').version")
if [ "$PACKAGE_VERSION" != "${{ env.RELEASE_TAG }}" ]; then
echo "::error file=package.json::Version $PACKAGE_VERSION doesn't match tag ${{ env.RELEASE_TAG }}"
exit 1
fi
build:
name: Build
runs-on: ubuntu-latest
# For workflow_dispatch: wait for check. For push: run immediately
needs: check
if: always() && (needs.check.result == 'success' || needs.check.result == 'skipped')
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup and Build
uses: ./.github/actions/setup-and-build
- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: build-artifacts
path: |
dist/
build/
publish-npm:
name: Publish to npm registry
runs-on: ubuntu-latest
needs: build
if: success()
permissions:
contents: read
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
name: build-artifacts
- name: Setup Node.js for npm registry
uses: actions/setup-node@v4
with:
node-version: '20'
registry-url: 'https://registry.npmjs.org'
- name: Publish to npm
run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
create-release:
name: Create GitHub Release
runs-on: ubuntu-latest
needs: publish-npm
# Only create GitHub release for manual workflow_dispatch (not test pushes)
if: github.event_name == 'workflow_dispatch'
permissions:
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Create Git Tag
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git tag ${{ env.RELEASE_TAG }}
git push origin ${{ env.RELEASE_TAG }}
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ env.RELEASE_TAG }}
name: Release ${{ env.RELEASE_TAG }}
generate_release_notes: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}