Skip to content

Commit cb6e45a

Browse files
authored
Prepare for release (#9605)
* rename `build-cli.yml` to `prepare-release.yml` In other repo's we will also have a `prepare-release` so this makes it a bit more consistent. * use common CONSTANT_CASE for environment variables * use `strategy` for defining the node version * add script to get the release notes * add release notes to release draft * use CONSTANT_CASE for environment variables * improve consistency for relase related scripts
1 parent ddb9b4d commit cb6e45a

File tree

7 files changed

+77
-30
lines changed

7 files changed

+77
-30
lines changed

.github/workflows/build-cli.yml renamed to .github/workflows/prepare-release.yml

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Build Standalone CLI
1+
name: Prepare Release
22

33
on:
44
workflow_dispatch:
@@ -13,10 +13,16 @@ permissions:
1313
contents: read
1414

1515
jobs:
16-
build_cli:
16+
build:
1717
permissions:
1818
contents: write # for softprops/action-gh-release to create GitHub release
19+
1920
runs-on: macos-11
21+
22+
strategy:
23+
matrix:
24+
node-version: [16]
25+
2026
steps:
2127
- uses: actions/checkout@v3
2228

@@ -25,12 +31,19 @@ jobs:
2531
- name: Resolve version
2632
id: vars
2733
run: |
28-
echo "tag_name=$(git describe --tags --abbrev=0)" >> $GITHUB_ENV
34+
echo "TAG_NAME=$(git describe --tags --abbrev=0)" >> $GITHUB_ENV
2935
30-
- name: Use Node.js 16
36+
- name: Get release notes
37+
run: |
38+
RELEASE_NOTES=$(npm run release-notes --silent)
39+
echo "RELEASE_NOTES<<EOF" >> $GITHUB_ENV
40+
echo "$RELEASE_NOTES" >> $GITHUB_ENV
41+
echo "EOF" >> $GITHUB_ENV
42+
43+
- name: Use Node.js ${{ matrix.node-version }}
3144
uses: actions/setup-node@v3
3245
with:
33-
node-version: '16'
46+
node-version: ${{ matrix.node-version }}
3447
registry-url: 'https://registry.npmjs.org'
3548

3649
- name: Build tailwindcss
@@ -52,14 +65,16 @@ jobs:
5265
uses: softprops/action-gh-release@v1
5366
with:
5467
draft: true
55-
tag_name: ${{ env.tag_name }}
68+
tag_name: ${{ env.TAG_NAME }}
5669
body: |
57-
* [Linux (arm64)](https://github.com/tailwindlabs/tailwindcss/releases/download/${{ env.tag_name }}/tailwindcss-linux-arm64)
58-
* [Linux (armv7)](https://github.com/tailwindlabs/tailwindcss/releases/download/${{ env.tag_name }}/tailwindcss-linux-armv7)
59-
* [Linux (x64)](https://github.com/tailwindlabs/tailwindcss/releases/download/${{ env.tag_name }}/tailwindcss-linux-x64)
60-
* [macOS (arm64)](https://github.com/tailwindlabs/tailwindcss/releases/download/${{ env.tag_name }}/tailwindcss-macos-arm64)
61-
* [macOS (x64)](https://github.com/tailwindlabs/tailwindcss/releases/download/${{ env.tag_name }}/tailwindcss-macos-x64)
62-
* [Windows (x64)](https://github.com/tailwindlabs/tailwindcss/releases/download/${{ env.tag_name }}/tailwindcss-windows-x64.exe)
70+
${{ env.RELEASE_NOTES }}
71+
72+
* [Linux (arm64)](https://github.com/tailwindlabs/tailwindcss/releases/download/${{ env.TAG_NAME }}/tailwindcss-linux-arm64)
73+
* [Linux (armv7)](https://github.com/tailwindlabs/tailwindcss/releases/download/${{ env.TAG_NAME }}/tailwindcss-linux-armv7)
74+
* [Linux (x64)](https://github.com/tailwindlabs/tailwindcss/releases/download/${{ env.TAG_NAME }}/tailwindcss-linux-x64)
75+
* [macOS (arm64)](https://github.com/tailwindlabs/tailwindcss/releases/download/${{ env.TAG_NAME }}/tailwindcss-macos-arm64)
76+
* [macOS (x64)](https://github.com/tailwindlabs/tailwindcss/releases/download/${{ env.TAG_NAME }}/tailwindcss-macos-x64)
77+
* [Windows (x64)](https://github.com/tailwindlabs/tailwindcss/releases/download/${{ env.TAG_NAME }}/tailwindcss-windows-x64.exe)
6378
files: |
6479
standalone-cli/dist/tailwindcss-linux-arm64
6580
standalone-cli/dist/tailwindcss-linux-armv7

.github/workflows/release-insiders.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,10 @@ jobs:
6161
- name: Resolve version
6262
id: vars
6363
run: |
64-
echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
64+
echo "SHA_SHORT=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
6565
66-
- name: 'Version based on commit: 0.0.0-insiders.${{ env.sha_short }}'
67-
run: npm version 0.0.0-insiders.${{ env.sha_short }} --force --no-git-tag-version
66+
- name: 'Version based on commit: 0.0.0-insiders.${{ env.SHA_SHORT }}'
67+
run: npm version 0.0.0-insiders.${{ env.SHA_SHORT }} --force --no-git-tag-version
6868

6969
- name: Publish
7070
run: npm publish --tag insiders
@@ -83,6 +83,6 @@ jobs:
8383
ref: 'master',
8484
workflow_id: 'upgrade-tailwindcss.yml',
8585
inputs: {
86-
insidersVersion: '0.0.0-insiders.${{ env.sha_short }}'
86+
insidersVersion: '0.0.0-insiders.${{ env.SHA_SHORT }}'
8787
}
8888
})

.github/workflows/release.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,17 +47,17 @@ jobs:
4747

4848
- name: Calculate environment variables
4949
run: |
50-
echo "tag_name=$(npm run calculate-tag-name --silent)" >> $GITHUB_ENV
51-
echo "tailwindcss_version=$(node -e 'console.log(require(`./package.json`).version);')" >> $GITHUB_ENV
50+
echo "RELEASE_CHANNEL=$(npm run release-channel --silent)" >> $GITHUB_ENV
51+
echo "TAILWINDCSS_VERSION=$(node -e 'console.log(require(`./package.json`).version);')" >> $GITHUB_ENV
5252
5353
- name: Publish
54-
run: npm publish --tag ${{ env.tag_name }}
54+
run: npm publish --tag ${{ env.RELEASE_CHANNEL }}
5555
env:
5656
CI: true
5757
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
5858

5959
- name: Trigger Tailwind Play update
60-
if: env.tag_name == 'latest'
60+
if: env.RELEASE_CHANNEL == 'latest'
6161
uses: actions/github-script@v6
6262
with:
6363
github-token: ${{ secrets.TAILWIND_PLAY_TOKEN }}
@@ -68,6 +68,6 @@ jobs:
6868
ref: 'master',
6969
workflow_id: 'upgrade-tailwindcss.yml',
7070
inputs: {
71-
version: '${{ env.tailwindcss_version }}'
71+
version: '${{ env.TAILWINDCSS_VERSION }}'
7272
}
7373
})

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@
2727
"generate:plugin-list": "node -r @swc/register scripts/create-plugin-list.js",
2828
"generate:types": "node -r @swc/register scripts/generate-types.js",
2929
"generate": "npm run generate:plugin-list && npm run generate:types",
30-
"calculate-tag-name": "node scripts/calculate-tag-name.js"
30+
"release-channel": "node ./scripts/release-channel.js",
31+
"release-notes": "node ./scripts/release-notes.js"
3132
},
3233
"files": [
3334
"src/*",

scripts/calculate-tag-name.js

Lines changed: 0 additions & 8 deletions
This file was deleted.

scripts/release-channel.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Given a version, figure out what the release channel is so that we can publish to the correct
2+
// channel on npm.
3+
//
4+
// E.g.:
5+
//
6+
// 1.2.3 -> latest (default)
7+
// 0.0.0-insiders.ffaa88 -> insiders
8+
// 4.1.0-alpha.4 -> alpha
9+
10+
let version =
11+
process.argv[2] || process.env.npm_package_version || require('../package.json').version
12+
13+
let match = /\d+\.\d+\.\d+-(.*)\.\d+/g.exec(version)
14+
if (match) {
15+
console.log(match[1])
16+
} else {
17+
console.log('latest')
18+
}

scripts/release-notes.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// Given a version, figure out what the release notes are so that we can use this to pre-fill the
2+
// relase notes on a GitHub release for the current version.
3+
4+
let path = require('path')
5+
let fs = require('fs')
6+
7+
let version =
8+
process.argv[2] || process.env.npm_package_version || require('../package.json').version
9+
10+
let changelog = fs.readFileSync(path.resolve(__dirname, '..', 'CHANGELOG.md'), 'utf8')
11+
let match = new RegExp(
12+
`## \\[${version}\\] - (.*)\\n\\n([\\s\\S]*?)\\n(?:(?:##\\s)|(?:\\[))`,
13+
'g'
14+
).exec(changelog)
15+
16+
if (match) {
17+
let [, , notes] = match
18+
console.log(notes.trim())
19+
} else {
20+
console.log(`Placeholder release notes for version: v${version}`)
21+
}

0 commit comments

Comments
 (0)