-
Notifications
You must be signed in to change notification settings - Fork 0
189 lines (161 loc) · 5.79 KB
/
release.yml
File metadata and controls
189 lines (161 loc) · 5.79 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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
name: Release & Publish
on:
push:
branches:
- main
workflow_dispatch:
concurrency:
group: release-${{ github.ref }}
cancel-in-progress: false
jobs:
# First run the full CI pipeline
ci:
name: CI Pipeline
uses: ./.github/workflows/ci.yml
if: >
contains(github.event.head_commit.message, 'chore: version packages') ||
contains(github.event.head_commit.message, 'Release: Version Packages') ||
github.event_name == 'workflow_dispatch'
release:
name: Release & Publish
runs-on: ubuntu-latest
timeout-minutes: 15
permissions:
contents: write
id-token: write
packages: write
# Only run if CI passes
needs: [ci]
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
# This makes Actions fetch all Git history so that Changesets can generate changelogs with the correct commits
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
registry-url: 'https://registry.npmjs.org'
scope: '@easythread'
- name: Install pnpm
uses: pnpm/action-setup@v2
with:
version: 10.13.1
- name: Get pnpm store directory
id: pnpm-cache
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
- name: Setup pnpm cache
uses: actions/cache@v3
with:
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Build packages
run: pnpm build
- name: Setup NPM authentication
run: |
echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > ~/.npmrc
echo "Current NPM user:"
npm whoami
echo ""
echo "Checking NPM token permissions:"
npm token list 2>/dev/null || echo "Could not list tokens (this is normal with publish tokens)"
echo ""
echo "Checking @easythread organization access:"
npm org ls @easythread 2>/dev/null || echo "Organization not accessible or doesn't exist"
echo ""
echo "Checking if we can access the organization packages:"
npm access list packages @easythread 2>/dev/null || echo "No packages found or no access (expected for first publish)"
echo ""
echo "Testing package publish permissions (dry run):"
cd packages/core
npm publish --dry-run --access public || echo "Dry run failed - this will help identify the issue"
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Create Release Pull Request or Publish to npm
id: changesets
uses: changesets/action@v1
with:
# This expects you to have a script called release which does a build for your packages and calls changeset publish
publish: pnpm release
title: "Release: Version Packages"
commit: "chore: version packages"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Send Slack notification on release
if: steps.changesets.outputs.published == 'true'
run: |
echo "🎉 New release published!"
echo "Published packages: ${{ steps.changesets.outputs.publishedPackages }}"
# Create GitHub releases when packages are published
create-github-release:
name: Create GitHub Release
runs-on: ubuntu-latest
needs: [release]
if: needs.release.outputs.published == 'true'
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Install pnpm
uses: pnpm/action-setup@v2
with:
version: 10.13.1
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Get latest version
id: version
run: |
VERSION=$(node -p "require('./packages/core/package.json').version")
echo "version=v$VERSION" >> $GITHUB_OUTPUT
- name: Generate changelog
id: changelog
run: |
if [ -f "CHANGELOG.md" ]; then
echo "changelog<<EOF" >> $GITHUB_OUTPUT
head -n 50 CHANGELOG.md >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
else
echo "changelog=New release with latest changes" >> $GITHUB_OUTPUT
fi
- name: Create GitHub Release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.version.outputs.version }}
release_name: ${{ steps.version.outputs.version }}
body: |
## 🎉 New Release
${{ steps.changelog.outputs.changelog }}
### 📦 Published Packages
- `@easythread/core`
- `@easythread/vite`
- `@easythread/rollup`
- `@easythread/esbuild`
### 🚀 Installation
```bash
# Core package
npm install @easythread/core
# Plugin for your bundler
npm install @easythread/vite
npm install @easythread/rollup
npm install @easythread/esbuild
```
**Full Changelog**: https://github.com/leka74/easythread/compare/${{ github.event.before }}...${{ github.sha }}
draft: false
prerelease: false