Skip to content

Commit

Permalink
improve consistency for relase related scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
RobinMalfait committed Oct 19, 2022
1 parent e2bb8bf commit a1b720e
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 13 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/release.yml
Expand Up @@ -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 }}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -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": [
Expand Down
8 changes: 0 additions & 8 deletions scripts/calculate-tag-name.js

This file was deleted.

18 changes: 18 additions & 0 deletions 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')
}
7 changes: 6 additions & 1 deletion 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)|(?:\\[))`,
Expand Down

0 comments on commit a1b720e

Please sign in to comment.