-
Notifications
You must be signed in to change notification settings - Fork 1
157 lines (131 loc) · 4.56 KB
/
Copy pathrelease.yaml
File metadata and controls
157 lines (131 loc) · 4.56 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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
name: Release Package
on:
push:
branches:
- main
- master
workflow_dispatch:
inputs:
release-type:
description: 'Release type (patch, minor, major)'
required: true
default: 'patch'
type: choice
options:
- patch
- minor
- major
permissions:
contents: write
packages: write
jobs:
check-version:
name: Check Version and Prepare Release
runs-on: ubuntu-latest
outputs:
should-release: ${{ steps.check.outputs.should-release }}
version: ${{ steps.check.outputs.version }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Check if version changed
id: check
run: |
# Get current version from package.json
CURRENT_VERSION=$(node -p "require('./package.json').version")
echo "Current version: $CURRENT_VERSION"
# Check if tag already exists
if git tag | grep -q "^v$CURRENT_VERSION$"; then
echo "Tag v$CURRENT_VERSION already exists. Skipping release."
echo "should-release=false" >> $GITHUB_OUTPUT
else
echo "Tag v$CURRENT_VERSION does not exist. Proceeding with release."
echo "should-release=true" >> $GITHUB_OUTPUT
echo "version=$CURRENT_VERSION" >> $GITHUB_OUTPUT
fi
release:
name: Build and Publish
needs: check-version
if: needs.check-version.outputs.should-release == 'true'
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 22.x
registry-url: 'https://registry.npmjs.org'
- name: Install dependencies
run: npm install
- name: Run tests
run: npm test
- name: Build package
run: npm run build
- name: Validate build output
run: |
# Check that dist directory exists and contains files
if [ ! -d "dist" ] || [ -z "$(ls -A dist)" ]; then
echo "::error::Build output directory 'dist' is empty or missing"
exit 1
fi
# Check that main entry point exists
if [ ! -f "dist/index.js" ]; then
echo "::error::Main entry point 'dist/index.js' is missing"
exit 1
fi
# Check that type definitions exist
if [ ! -f "dist/index.d.ts" ]; then
echo "::error::Type definitions 'dist/index.d.ts' are missing"
exit 1
fi
# Check that CLI entry point exists
if [ ! -f "bin/stm" ]; then
echo "::error::CLI entry point 'bin/stm' is missing"
exit 1
fi
echo "Build validation passed ✓"
- name: Create release tag
run: |
VERSION=${{ needs.check-version.outputs.version }}
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git tag -a "v$VERSION" -m "Release v$VERSION"
git push origin "v$VERSION"
- name: Publish to npm
run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Create GitHub Release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: v${{ needs.check-version.outputs.version }}
release_name: Release v${{ needs.check-version.outputs.version }}
body: |
## Simple Task Master v${{ needs.check-version.outputs.version }}
### Installation
```bash
npm install -g simple-task-master@${{ needs.check-version.outputs.version }}
```
### What's Changed
Please see the [changelog](https://github.com/${{ github.repository }}/compare/v${{ needs.check-version.outputs.version }}...HEAD) for details.
### Full Changelog
https://github.com/${{ github.repository }}/commits/v${{ needs.check-version.outputs.version }}
draft: false
prerelease: false
post-release:
name: Post-Release Actions
needs: [check-version, release]
if: needs.check-version.outputs.should-release == 'true'
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Notify on failure
if: failure()
run: |
echo "::error::Release failed! Please check the logs and fix any issues."