From 1b554ae14d12a42702adb228b0aa3c0287e44b7d Mon Sep 17 00:00:00 2001 From: Robin Malfait Date: Wed, 19 Oct 2022 15:05:49 +0200 Subject: [PATCH 1/7] 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. --- .github/workflows/{build-cli.yml => prepare-release.yml} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename .github/workflows/{build-cli.yml => prepare-release.yml} (98%) diff --git a/.github/workflows/build-cli.yml b/.github/workflows/prepare-release.yml similarity index 98% rename from .github/workflows/build-cli.yml rename to .github/workflows/prepare-release.yml index 7e47eadf9378..46f081b6355f 100644 --- a/.github/workflows/build-cli.yml +++ b/.github/workflows/prepare-release.yml @@ -1,4 +1,4 @@ -name: Build Standalone CLI +name: Prepare Release on: workflow_dispatch: From 39b75ccc3195026caad3439f8767d856872478ee Mon Sep 17 00:00:00 2001 From: Robin Malfait Date: Wed, 19 Oct 2022 15:06:52 +0200 Subject: [PATCH 2/7] use common CONSTANT_CASE for environment variables --- .github/workflows/prepare-release.yml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/prepare-release.yml b/.github/workflows/prepare-release.yml index 46f081b6355f..a914e08efd87 100644 --- a/.github/workflows/prepare-release.yml +++ b/.github/workflows/prepare-release.yml @@ -25,7 +25,7 @@ jobs: - name: Resolve version id: vars run: | - echo "tag_name=$(git describe --tags --abbrev=0)" >> $GITHUB_ENV + echo "TAG_NAME=$(git describe --tags --abbrev=0)" >> $GITHUB_ENV - name: Use Node.js 16 uses: actions/setup-node@v3 @@ -52,14 +52,14 @@ jobs: uses: softprops/action-gh-release@v1 with: draft: true - tag_name: ${{ env.tag_name }} + tag_name: ${{ env.TAG_NAME }} body: | - * [Linux (arm64)](https://github.com/tailwindlabs/tailwindcss/releases/download/${{ env.tag_name }}/tailwindcss-linux-arm64) - * [Linux (armv7)](https://github.com/tailwindlabs/tailwindcss/releases/download/${{ env.tag_name }}/tailwindcss-linux-armv7) - * [Linux (x64)](https://github.com/tailwindlabs/tailwindcss/releases/download/${{ env.tag_name }}/tailwindcss-linux-x64) - * [macOS (arm64)](https://github.com/tailwindlabs/tailwindcss/releases/download/${{ env.tag_name }}/tailwindcss-macos-arm64) - * [macOS (x64)](https://github.com/tailwindlabs/tailwindcss/releases/download/${{ env.tag_name }}/tailwindcss-macos-x64) - * [Windows (x64)](https://github.com/tailwindlabs/tailwindcss/releases/download/${{ env.tag_name }}/tailwindcss-windows-x64.exe) + * [Linux (arm64)](https://github.com/tailwindlabs/tailwindcss/releases/download/${{ env.TAG_NAME }}/tailwindcss-linux-arm64) + * [Linux (armv7)](https://github.com/tailwindlabs/tailwindcss/releases/download/${{ env.TAG_NAME }}/tailwindcss-linux-armv7) + * [Linux (x64)](https://github.com/tailwindlabs/tailwindcss/releases/download/${{ env.TAG_NAME }}/tailwindcss-linux-x64) + * [macOS (arm64)](https://github.com/tailwindlabs/tailwindcss/releases/download/${{ env.TAG_NAME }}/tailwindcss-macos-arm64) + * [macOS (x64)](https://github.com/tailwindlabs/tailwindcss/releases/download/${{ env.TAG_NAME }}/tailwindcss-macos-x64) + * [Windows (x64)](https://github.com/tailwindlabs/tailwindcss/releases/download/${{ env.TAG_NAME }}/tailwindcss-windows-x64.exe) files: | standalone-cli/dist/tailwindcss-linux-arm64 standalone-cli/dist/tailwindcss-linux-armv7 From 14c16b5ba27cb0ef1e1daa360feaaa71d2b38b3b Mon Sep 17 00:00:00 2001 From: Robin Malfait Date: Wed, 19 Oct 2022 15:09:14 +0200 Subject: [PATCH 3/7] use `strategy` for defining the node version --- .github/workflows/prepare-release.yml | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/.github/workflows/prepare-release.yml b/.github/workflows/prepare-release.yml index a914e08efd87..da2087bd2715 100644 --- a/.github/workflows/prepare-release.yml +++ b/.github/workflows/prepare-release.yml @@ -13,10 +13,16 @@ permissions: contents: read jobs: - build_cli: + build: permissions: contents: write # for softprops/action-gh-release to create GitHub release + runs-on: macos-11 + + strategy: + matrix: + node-version: [16] + steps: - uses: actions/checkout@v3 @@ -27,10 +33,10 @@ jobs: run: | echo "TAG_NAME=$(git describe --tags --abbrev=0)" >> $GITHUB_ENV - - name: Use Node.js 16 + - name: Use Node.js ${{ matrix.node-version }} uses: actions/setup-node@v3 with: - node-version: '16' + node-version: ${{ matrix.node-version }} registry-url: 'https://registry.npmjs.org' - name: Build tailwindcss From e9801bc4b45f646b2b30d444fb9674252d30aa86 Mon Sep 17 00:00:00 2001 From: Robin Malfait Date: Wed, 19 Oct 2022 15:15:24 +0200 Subject: [PATCH 4/7] add script to get the release notes --- package.json | 3 ++- scripts/release-notes.js | 16 ++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 scripts/release-notes.js diff --git a/package.json b/package.json index 645128fd4157..8be67fdad9f8 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,8 @@ "generate:plugin-list": "node -r @swc/register scripts/create-plugin-list.js", "generate:types": "node -r @swc/register scripts/generate-types.js", "generate": "npm run generate:plugin-list && npm run generate:types", - "calculate-tag-name": "node scripts/calculate-tag-name.js" + "calculate-tag-name": "node scripts/calculate-tag-name.js", + "release-notes": "node ./scripts/release-notes.js" }, "files": [ "src/*", diff --git a/scripts/release-notes.js b/scripts/release-notes.js new file mode 100644 index 000000000000..97feef884f5d --- /dev/null +++ b/scripts/release-notes.js @@ -0,0 +1,16 @@ +let path = require('path') +let fs = require('fs') + +let version = process.argv[2] || require('../package.json').version +let changelog = fs.readFileSync(path.resolve(__dirname, '..', 'CHANGELOG.md'), 'utf8') +let match = new RegExp( + `## \\[${version}\\] - (.*)\\n\\n([\\s\\S]*?)\\n(?:(?:##\\s)|(?:\\[))`, + 'g' +).exec(changelog) + +if (match) { + let [, date, notes] = match + console.log(notes.trim()) +} else { + console.log(`Placeholder release notes for version: v${version}`) +} From 34d171a599e36e63b27f683619f550de9b67113a Mon Sep 17 00:00:00 2001 From: Robin Malfait Date: Wed, 19 Oct 2022 15:15:46 +0200 Subject: [PATCH 5/7] add release notes to release draft --- .github/workflows/prepare-release.yml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.github/workflows/prepare-release.yml b/.github/workflows/prepare-release.yml index da2087bd2715..6dfeb3a84179 100644 --- a/.github/workflows/prepare-release.yml +++ b/.github/workflows/prepare-release.yml @@ -33,6 +33,13 @@ jobs: run: | echo "TAG_NAME=$(git describe --tags --abbrev=0)" >> $GITHUB_ENV + - name: Get release notes + run: | + RELEASE_NOTES=$(npm run release-notes --silent) + echo "RELEASE_NOTES<> $GITHUB_ENV + echo "$RELEASE_NOTES" >> $GITHUB_ENV + echo "EOF" >> $GITHUB_ENV + - name: Use Node.js ${{ matrix.node-version }} uses: actions/setup-node@v3 with: @@ -60,6 +67,8 @@ jobs: draft: true tag_name: ${{ env.TAG_NAME }} body: | + ${{ env.RELEASE_NOTES }} + * [Linux (arm64)](https://github.com/tailwindlabs/tailwindcss/releases/download/${{ env.TAG_NAME }}/tailwindcss-linux-arm64) * [Linux (armv7)](https://github.com/tailwindlabs/tailwindcss/releases/download/${{ env.TAG_NAME }}/tailwindcss-linux-armv7) * [Linux (x64)](https://github.com/tailwindlabs/tailwindcss/releases/download/${{ env.TAG_NAME }}/tailwindcss-linux-x64) From e2bb8bf37205e711e33fabf108bf40020980bc98 Mon Sep 17 00:00:00 2001 From: Robin Malfait Date: Wed, 19 Oct 2022 15:17:08 +0200 Subject: [PATCH 6/7] use CONSTANT_CASE for environment variables --- .github/workflows/release-insiders.yml | 8 ++++---- .github/workflows/release.yml | 10 +++++----- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/workflows/release-insiders.yml b/.github/workflows/release-insiders.yml index a55883a22c52..2e55b18d7053 100644 --- a/.github/workflows/release-insiders.yml +++ b/.github/workflows/release-insiders.yml @@ -61,10 +61,10 @@ jobs: - name: Resolve version id: vars run: | - echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_ENV + echo "SHA_SHORT=$(git rev-parse --short HEAD)" >> $GITHUB_ENV - - name: 'Version based on commit: 0.0.0-insiders.${{ env.sha_short }}' - run: npm version 0.0.0-insiders.${{ env.sha_short }} --force --no-git-tag-version + - name: 'Version based on commit: 0.0.0-insiders.${{ env.SHA_SHORT }}' + run: npm version 0.0.0-insiders.${{ env.SHA_SHORT }} --force --no-git-tag-version - name: Publish run: npm publish --tag insiders @@ -83,6 +83,6 @@ jobs: ref: 'master', workflow_id: 'upgrade-tailwindcss.yml', inputs: { - insidersVersion: '0.0.0-insiders.${{ env.sha_short }}' + insidersVersion: '0.0.0-insiders.${{ env.SHA_SHORT }}' } }) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index e54466bdb69c..1d2e8ef3be53 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -47,17 +47,17 @@ jobs: - name: Calculate environment variables run: | - echo "tag_name=$(npm run calculate-tag-name --silent)" >> $GITHUB_ENV - echo "tailwindcss_version=$(node -e 'console.log(require(`./package.json`).version);')" >> $GITHUB_ENV + echo "TAG_NAME=$(npm run calculate-tag-name --silent)" >> $GITHUB_ENV + echo "TAILWINDCSS_VERSION=$(node -e 'console.log(require(`./package.json`).version);')" >> $GITHUB_ENV - name: Publish - run: npm publish --tag ${{ env.tag_name }} + run: npm publish --tag ${{ env.TAG_NAME }} env: CI: true NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} - name: Trigger Tailwind Play update - if: env.tag_name == 'latest' + if: env.TAG_NAME == 'latest' uses: actions/github-script@v6 with: github-token: ${{ secrets.TAILWIND_PLAY_TOKEN }} @@ -68,6 +68,6 @@ jobs: ref: 'master', workflow_id: 'upgrade-tailwindcss.yml', inputs: { - version: '${{ env.tailwindcss_version }}' + version: '${{ env.TAILWINDCSS_VERSION }}' } }) From 69d4f30285034f9e3cc195cab3a75d05b80ac958 Mon Sep 17 00:00:00 2001 From: Robin Malfait Date: Wed, 19 Oct 2022 15:42:20 +0200 Subject: [PATCH 7/7] improve consistency for relase related scripts --- .github/workflows/release.yml | 6 +++--- package.json | 2 +- scripts/calculate-tag-name.js | 8 -------- scripts/release-channel.js | 18 ++++++++++++++++++ scripts/release-notes.js | 9 +++++++-- 5 files changed, 29 insertions(+), 14 deletions(-) delete mode 100644 scripts/calculate-tag-name.js create mode 100644 scripts/release-channel.js diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 1d2e8ef3be53..dbd03894a7fd 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -47,17 +47,17 @@ jobs: - name: Calculate environment variables run: | - echo "TAG_NAME=$(npm run calculate-tag-name --silent)" >> $GITHUB_ENV + echo "RELEASE_CHANNEL=$(npm run release-channel --silent)" >> $GITHUB_ENV echo "TAILWINDCSS_VERSION=$(node -e 'console.log(require(`./package.json`).version);')" >> $GITHUB_ENV - name: Publish - run: npm publish --tag ${{ env.TAG_NAME }} + run: npm publish --tag ${{ env.RELEASE_CHANNEL }} env: CI: true NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} - name: Trigger Tailwind Play update - if: env.TAG_NAME == 'latest' + if: env.RELEASE_CHANNEL == 'latest' uses: actions/github-script@v6 with: github-token: ${{ secrets.TAILWIND_PLAY_TOKEN }} diff --git a/package.json b/package.json index 8be67fdad9f8..9486e39d7013 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,7 @@ "generate:plugin-list": "node -r @swc/register scripts/create-plugin-list.js", "generate:types": "node -r @swc/register scripts/generate-types.js", "generate": "npm run generate:plugin-list && npm run generate:types", - "calculate-tag-name": "node scripts/calculate-tag-name.js", + "release-channel": "node ./scripts/release-channel.js", "release-notes": "node ./scripts/release-notes.js" }, "files": [ diff --git a/scripts/calculate-tag-name.js b/scripts/calculate-tag-name.js deleted file mode 100644 index 7d9cd7939e19..000000000000 --- a/scripts/calculate-tag-name.js +++ /dev/null @@ -1,8 +0,0 @@ -let version = process.env.npm_package_version || require('../package.json').version - -let match = /\d+\.\d+\.\d+-(.*)\.\d+/g.exec(version) -if (match) { - console.log(match[1]) -} else { - console.log('latest') -} diff --git a/scripts/release-channel.js b/scripts/release-channel.js new file mode 100644 index 000000000000..0c827f3fda8c --- /dev/null +++ b/scripts/release-channel.js @@ -0,0 +1,18 @@ +// Given a version, figure out what the release channel is so that we can publish to the correct +// channel on npm. +// +// E.g.: +// +// 1.2.3 -> latest (default) +// 0.0.0-insiders.ffaa88 -> insiders +// 4.1.0-alpha.4 -> alpha + +let version = + process.argv[2] || process.env.npm_package_version || require('../package.json').version + +let match = /\d+\.\d+\.\d+-(.*)\.\d+/g.exec(version) +if (match) { + console.log(match[1]) +} else { + console.log('latest') +} diff --git a/scripts/release-notes.js b/scripts/release-notes.js index 97feef884f5d..bd29e952d889 100644 --- a/scripts/release-notes.js +++ b/scripts/release-notes.js @@ -1,7 +1,12 @@ +// Given a version, figure out what the release notes are so that we can use this to pre-fill the +// relase notes on a GitHub release for the current version. + let path = require('path') let fs = require('fs') -let version = process.argv[2] || require('../package.json').version +let version = + process.argv[2] || process.env.npm_package_version || require('../package.json').version + let changelog = fs.readFileSync(path.resolve(__dirname, '..', 'CHANGELOG.md'), 'utf8') let match = new RegExp( `## \\[${version}\\] - (.*)\\n\\n([\\s\\S]*?)\\n(?:(?:##\\s)|(?:\\[))`, @@ -9,7 +14,7 @@ let match = new RegExp( ).exec(changelog) if (match) { - let [, date, notes] = match + let [, , notes] = match console.log(notes.trim()) } else { console.log(`Placeholder release notes for version: v${version}`)