From 6a6ffb68839ef5db9d810c389528fb253f19dfb0 Mon Sep 17 00:00:00 2001 From: dtinth on MBP M1 Date: Fri, 30 Dec 2022 13:18:50 +0700 Subject: [PATCH 01/16] Add release script --- .github/workflows/ci.yml | 13 ++- bemuse/package.json | 2 +- build-scripts/index.js | 130 ++++++++++++++++-------------- build-scripts/lib/changelog.js | 24 +++++- build-scripts/package.json | 1 + common/config/rush/pnpm-lock.yaml | 27 ++++++- 6 files changed, 130 insertions(+), 67 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8ab00c00..b5e4f4ea 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -4,6 +4,7 @@ on: push: branches: - master + - cd-release pull_request: branches: - master @@ -30,8 +31,17 @@ jobs: node build-scripts build env: SCOREBOARD_SERVER: ${{ secrets.SCOREBOARD_SERVER }} + - name: Compress build output + if: always() + run: tar -cvzf dist.tar.gz dist - name: Checks run: node build-scripts pre-deploy + - name: Release + if: github.event_name == 'push' + run: | + node build-scripts release + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Deploy if: false run: | @@ -53,9 +63,6 @@ jobs: fi env: GH_APP_CREDENTIALS_TOKEN: ${{ secrets.GH_APP_CREDENTIALS_TOKEN }} - - name: Compress build output - if: always() - run: tar -cvzf dist.tar.gz dist - name: Upload artifact if: always() uses: actions/upload-artifact@v3 diff --git a/bemuse/package.json b/bemuse/package.json index 818a48ca..e3039b40 100644 --- a/bemuse/package.json +++ b/bemuse/package.json @@ -1,6 +1,6 @@ { "name": "bemuse", - "version": "53.2.0", + "version": "53.2.0-pre.0", "description": "BEAT☆MUSIC☆SEQUENCE, a web-based music game of the future", "private": true, "browserslist": [ diff --git a/build-scripts/index.js b/build-scripts/index.js index 7fddfeca..acfe116a 100644 --- a/build-scripts/index.js +++ b/build-scripts/index.js @@ -10,7 +10,8 @@ const glob = require('glob') const matter = require('gray-matter') const semverInc = require('semver/functions/inc') const semverGt = require('semver/functions/gt') -const { updateChangelog } = require('./lib/changelog') +const tempWrite = require('temp-write') +const { updateChangelog, getReleaseChangelog } = require('./lib/changelog') yargs .demandCommand() @@ -92,9 +93,7 @@ yargs }, }, async (argv) => { - const currentVersion = JSON.parse( - fs.readFileSync('bemuse/package.json', 'utf8') - ).version + const currentVersion = getCurrentVersion() console.log(`Current version: ${currentVersion}`) let targetVersion = semverInc(currentVersion, 'patch') @@ -166,67 +165,55 @@ yargs fs.unlinkSync(file) } } - - const writeOutput = (key, value) => { - console.log(`Output: ${key}=${value}`) - if (process.env.GITHUB_OUTPUT) { - fs.appendFileSync(process.env.GITHUB_OUTPUT, `${key}=${value}\n`) - } - } writeOutput('version', targetVersion) } ) - .command('release', 'Release a new version of Bemuse', {}, async () => { - await run('git fetch') - await run('git checkout origin/master') - await run('git branch -d master || true') - await run('git checkout -b master') - await run('node build-scripts release:changelog') - const version = ( - await exec('node build-scripts release:get-next-version') - ).trim() - await exec( - `node build-scripts release:write-version --newVersion '${version}'` - ) - await run(`git commit -a -m ':bookmark: v${version}' || true`) - await run(`git tag "v${version}"`) - await run(`git push --follow-tags --set-upstream origin master`) - }) - .command( - 'release:changelog', - 'Remove prerelease version suffixes from CHANGELOG.md', - {}, - async () => { - const data = fs.readFileSync('CHANGELOG.md', 'utf8') - const date = new Date().toJSON().split('T')[0] - fs.writeFileSync( - 'CHANGELOG.md', - data.replace(/(## v[\d.]+?)(?:\.0)?(?:\.0)?-pre\.\d+/g, `$1 (${date})`) - ) - } - ) - .command( - 'release:get-next-version', - 'Prints the version of the upcoming release', - {}, - async () => { - const { version } = JSON.parse( - fs.readFileSync('bemuse/package.json', 'utf8') - ) - console.log(version.replace(/-.*/, '')) - } - ) .command( - 'release:write-version', - 'Sets the version of Bemuse project', - { newVersion: { type: 'string', demand: true } }, - async (args) => { - const contents = fs.readFileSync('bemuse/package.json', 'utf8') - const newContents = contents.replace( - /"version":\s*"([^"]+)"/, - `"version": "${args.newVersion}"` - ) - fs.writeFileSync('bemuse/package.json', newContents, 'utf8') + 'release', + 'Create GitHub Release', + { + confirm: { + alias: 'f', + type: 'boolean', + default: false, + description: 'Creates the release', + }, + }, + async (argv) => { + const sha = await exec('git rev-parse HEAD') + const currentVersion = getCurrentVersion() + console.log(`Current version: ${currentVersion}`) + + const gitTag = `v${currentVersion}` + const exitCode = await check(`gh release view ${gitTag}`) + if (exitCode === 0) { + console.log('Release already exists.') + return + } + + const changelog = fs.readFileSync('CHANGELOG.md', 'utf8') + const releaseNotes = + getReleaseChangelog(changelog, currentVersion) || + '(Release notes not found)' + const isPreRelease = currentVersion.includes('-') + const date = new Date().toISOString().split('T')[0] + const releaseName = `Bemuse v${currentVersion} (${date})` + const notesFile = tempWrite.sync(releaseNotes) + const releaseCommand = `gh release create ${gitTag} --title "${releaseName}" --notes-file ${notesFile} ${ + isPreRelease ? '--prerelease' : '' + } --target "${sha}"` + if (argv.confirm) { + await run(releaseCommand) + } else { + console.log('Dry-run: %s', releaseCommand) + } + + const uploadCommand = `gh release upload ${gitTag} dist.tar.gz` + if (argv.confirm) { + await run(uploadCommand) + } else { + console.log('Dry-run: %s', uploadCommand) + } } ) .command( @@ -255,6 +242,10 @@ yargs ) .parse() +function getCurrentVersion() { + return JSON.parse(fs.readFileSync('bemuse/package.json', 'utf8')).version +} + async function run(shellCommand) { console.error(`Running: "${shellCommand}"`) await execa(shellCommand, { @@ -263,6 +254,16 @@ async function run(shellCommand) { }) } +async function check(shellCommand) { + console.error(`Running: "${shellCommand}"`) + const result = await execa(shellCommand, { + shell: true, + stdio: 'inherit', + reject: false, + }) + return result.exitCode +} + async function exec(shellCommand) { console.error(`Running: "${shellCommand}"`) const result = await execa(shellCommand, { @@ -270,3 +271,10 @@ async function exec(shellCommand) { }) return result.stdout } + +function writeOutput(key, value) { + console.log(`Output: ${key}=${value}`) + if (process.env.GITHUB_OUTPUT) { + fs.appendFileSync(process.env.GITHUB_OUTPUT, `${key}=${value}\n`) + } +} diff --git a/build-scripts/lib/changelog.js b/build-scripts/lib/changelog.js index a6b36e0e..81887ab5 100644 --- a/build-scripts/lib/changelog.js +++ b/build-scripts/lib/changelog.js @@ -69,4 +69,26 @@ function updateChangelog(existingChangelog, entries, version = 'UNRELEASED') { const prettierConfig = JSON.parse(require('fs').readFileSync('.prettierrc', 'utf8')) return prettier.format(markdown, { ...prettierConfig, parser: 'markdown' }) } -exports.updateChangelog = updateChangelog \ No newline at end of file +exports.updateChangelog = updateChangelog + +/** + * Find the changelog for a specific release. + * @param {string} changelog + * @param {string} version + */ +function getReleaseChangelog(changelog, version) { + const lines = changelog.split('\n') + /** @type {string[] | undefined} */ + let output + for (const line of lines) { + if (line.trim().startsWith('## ' + version)) { + output = [] + } else if (output && line.trim().startsWith('## ')) { + break + } else if (output) { + output.push(line) + } + } + return output && output.join('\n') +} +exports.getReleaseChangelog = getReleaseChangelog \ No newline at end of file diff --git a/build-scripts/package.json b/build-scripts/package.json index f2f8b44e..fa59add2 100644 --- a/build-scripts/package.json +++ b/build-scripts/package.json @@ -13,6 +13,7 @@ "merge-stream": "^2.0.0", "prettier": "^2.7.1", "semver": "^7.3.8", + "temp-write": "^4.0.0", "vinyl-fs": "^3.0.3", "yargs": "^15.3.1", "zod": "^3.20.2" diff --git a/common/config/rush/pnpm-lock.yaml b/common/config/rush/pnpm-lock.yaml index 97e92d25..6dbe1c13 100644 --- a/common/config/rush/pnpm-lock.yaml +++ b/common/config/rush/pnpm-lock.yaml @@ -194,6 +194,7 @@ specifiers: strip-json-comments: ~5.0.0 style-loader: ^3.3.1 temp: ^0.8.1 + temp-write: ^4.0.0 terser-webpack-plugin: ^5.3.6 throat: ^2.0.2 through2: ^2.0.3 @@ -413,6 +414,7 @@ dependencies: strip-json-comments: 5.0.0 style-loader: 3.3.1_webpack@5.75.0 temp: 0.8.4 + temp-write: 4.0.0 terser-webpack-plugin: 5.3.6_webpack@5.75.0 throat: 2.0.2 through2: 2.0.5 @@ -19274,11 +19276,27 @@ packages: yallist: 4.0.0 dev: false + /temp-dir/1.0.0: + resolution: {integrity: sha512-xZFXEGbG7SNC3itwBzI3RYjq/cEhBkx2hJuKGIUOcEULmkQExXiHat2z/qkISYsuR+IKumhEfKKbV5qXmhICFQ==} + engines: {node: '>=4'} + dev: false + /temp-dir/2.0.0: resolution: {integrity: sha512-aoBAniQmmwtcKp/7BzsH8Cxzv8OL736p7v1ihGb5e9DJ9kTwGWHrQrVB5+lfVDzfGrdRzXch+ig7LHaY1JTOrg==} engines: {node: '>=8'} dev: false + /temp-write/4.0.0: + resolution: {integrity: sha512-HIeWmj77uOOHb0QX7siN3OtwV3CTntquin6TNVg6SHOqCP3hYKmox90eeFOGaY1MqJ9WYDDjkyZrW6qS5AWpbw==} + engines: {node: '>=8'} + dependencies: + graceful-fs: 4.2.10 + is-stream: 2.0.1 + make-dir: 3.1.0 + temp-dir: 1.0.0 + uuid: 3.4.0 + dev: false + /temp/0.8.4: resolution: {integrity: sha512-s0ZZzd0BzYv5tLSptZooSjK8oj6C+c19p7Vqta9+6NPOf7r+fxq0cJe6/oN4LTC79sy5NY8ucOJNgwsKCSbfqg==} engines: {node: '>=6.0.0'} @@ -20372,6 +20390,12 @@ packages: engines: {node: '>= 0.4.0'} dev: false + /uuid/3.4.0: + resolution: {integrity: sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==} + deprecated: Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details. + hasBin: true + dev: false + /uuid/8.3.2: resolution: {integrity: sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==} hasBin: true @@ -21797,7 +21821,7 @@ packages: dev: false file:projects/build-scripts.tgz: - resolution: {integrity: sha512-xY+tZW4qc2NnlL4W6De/tkHTHymFV9NZ5yZr2Ox6yTJySoZpLzvava+0HAjZh0Lj4rCKnB5VftBIZp0aORHAfA==, tarball: file:projects/build-scripts.tgz} + resolution: {integrity: sha512-23dA5HRJbNvbahyzpAMCMSkY6CqKIHToC+k/e3673HnarfPtOHEY5NOm2vtcofat0e/JacpGJEUpcZ9+vZg8Iw==, tarball: file:projects/build-scripts.tgz} name: '@rush-temp/build-scripts' version: 0.0.0 dependencies: @@ -21812,6 +21836,7 @@ packages: merge-stream: 2.0.0 prettier: 2.8.1 semver: 7.3.8 + temp-write: 4.0.0 typescript: 4.9.3 vinyl-fs: 3.0.3 yargs: 15.4.1 From dbb286f6317bfec22656bff808fc030851fbc258 Mon Sep 17 00:00:00 2001 From: dtinth on MBP M1 Date: Fri, 30 Dec 2022 13:20:05 +0700 Subject: [PATCH 02/16] Save release version --- .github/workflows/ci.yml | 1 + build-scripts/index.js | 2 ++ 2 files changed, 3 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b5e4f4ea..7a165b52 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -38,6 +38,7 @@ jobs: run: node build-scripts pre-deploy - name: Release if: github.event_name == 'push' + id: release run: | node build-scripts release env: diff --git a/build-scripts/index.js b/build-scripts/index.js index acfe116a..9386a1ab 100644 --- a/build-scripts/index.js +++ b/build-scripts/index.js @@ -214,6 +214,8 @@ yargs } else { console.log('Dry-run: %s', uploadCommand) } + + writeOutput('version', currentVersion) } ) .command( From ecd4738e70e75e1f0523d67ba29d4051278eec91 Mon Sep 17 00:00:00 2001 From: dtinth on MBP M1 Date: Fri, 30 Dec 2022 13:23:22 +0700 Subject: [PATCH 03/16] Confirm the release! --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7a165b52..56568e4c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -40,7 +40,7 @@ jobs: if: github.event_name == 'push' id: release run: | - node build-scripts release + node build-scripts release --confirm env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Deploy From 0464accca8e7d4601ac13ab4e63418960d852a55 Mon Sep 17 00:00:00 2001 From: dtinth on MBP M1 Date: Fri, 30 Dec 2022 13:34:40 +0700 Subject: [PATCH 04/16] Add production deployment script --- .github/workflows/deploy-production.yml | 54 +++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 .github/workflows/deploy-production.yml diff --git a/.github/workflows/deploy-production.yml b/.github/workflows/deploy-production.yml new file mode 100644 index 00000000..25d904b4 --- /dev/null +++ b/.github/workflows/deploy-production.yml @@ -0,0 +1,54 @@ +name: Deploy to production + +on: + workflow_dispatch: + inputs: + version: + description: 'Version to deploy' + required: true + workflow_call: + inputs: + version: + description: 'Version to deploy' + required: true + type: 'string' + +env: + NODE_FLAGS: --max_old_space_size=4096 + VERSION: ${{ inputs.version }} + +jobs: + deploy: + environment: + name: Production + url: https://bemuse.ninja + runs-on: ubuntu-latest + steps: + - name: Checkout Repository + uses: actions/checkout@v3 + - name: Set up project + uses: ./.github/actions/setup-project + - name: Download release + run: | + gh release download $VERSION --pattern dist.tar.gz + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Extract build + run: tar -xvzf dist.tar.gz + - name: Checks + run: node build-scripts pre-deploy + - name: Deploy + run: | + if [ -n "$GH_APP_CREDENTIALS_TOKEN" ] + then + GH_TOKEN="$(npx obtain-github-app-installation-access-token ci $GH_APP_CREDENTIALS_TOKEN)" + echo "::add-mask::$GH_TOKEN" + git remote add www https://akibot:$GH_TOKEN@github.com/bemusic/bemusic.github.io.git + git config --global user.email "aki@spacet.me" + git config --global user.name "Aki running on GitHub Actions" + node build-scripts deploy + else + echo "GH_APP_CREDENTIALS_TOKEN is not set, skipped" + fi + env: + GH_APP_CREDENTIALS_TOKEN: ${{ secrets.GH_APP_CREDENTIALS_TOKEN }} From 262d175f88dbcb80d31422ca8926fbc014f1434e Mon Sep 17 00:00:00 2001 From: dtinth on MBP M1 Date: Fri, 30 Dec 2022 13:38:39 +0700 Subject: [PATCH 05/16] Call deployment workflow from CI --- .github/workflows/ci.yml | 8 ++++++++ .github/workflows/deploy-production.yml | 16 ++++++++++------ bemuse/package.json | 2 +- build-scripts/index.js | 2 +- 4 files changed, 20 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 56568e4c..adf7ba00 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -70,6 +70,14 @@ jobs: with: name: bemuse-build-${{ github.sha }} path: dist.tar.gz + outputs: + released-tag: ${{ steps.release.outputs.tag }} + deploy: + uses: ./.github/workflows/deploy-production.yml + needs: build + secrets: inherit + with: + tag: ${{ needs.build.outputs.released-tag }} e2e: runs-on: ubuntu-latest needs: build diff --git a/.github/workflows/deploy-production.yml b/.github/workflows/deploy-production.yml index 25d904b4..bdfb3963 100644 --- a/.github/workflows/deploy-production.yml +++ b/.github/workflows/deploy-production.yml @@ -3,19 +3,23 @@ name: Deploy to production on: workflow_dispatch: inputs: - version: - description: 'Version to deploy' + tag: + description: 'Git tag to deploy' required: true workflow_call: inputs: - version: - description: 'Version to deploy' + tag: + description: 'Git tag to deploy' required: true type: 'string' + secrets: + GH_APP_CREDENTIALS_TOKEN: + description: 'GitHub App credentials token' + required: true env: NODE_FLAGS: --max_old_space_size=4096 - VERSION: ${{ inputs.version }} + TAG: ${{ inputs.tag }} jobs: deploy: @@ -30,7 +34,7 @@ jobs: uses: ./.github/actions/setup-project - name: Download release run: | - gh release download $VERSION --pattern dist.tar.gz + gh release download $TAG --pattern dist.tar.gz env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Extract build diff --git a/bemuse/package.json b/bemuse/package.json index e3039b40..1899bd60 100644 --- a/bemuse/package.json +++ b/bemuse/package.json @@ -1,6 +1,6 @@ { "name": "bemuse", - "version": "53.2.0-pre.0", + "version": "53.2.0-pre.1", "description": "BEAT☆MUSIC☆SEQUENCE, a web-based music game of the future", "private": true, "browserslist": [ diff --git a/build-scripts/index.js b/build-scripts/index.js index 9386a1ab..f7207066 100644 --- a/build-scripts/index.js +++ b/build-scripts/index.js @@ -215,7 +215,7 @@ yargs console.log('Dry-run: %s', uploadCommand) } - writeOutput('version', currentVersion) + writeOutput('tag', gitTag) } ) .command( From 1ea74c0486c093bc5cac68c2b0600a6f7bbd7820 Mon Sep 17 00:00:00 2001 From: dtinth on MBP M1 Date: Fri, 30 Dec 2022 13:45:05 +0700 Subject: [PATCH 06/16] Releasing works now! --- .github/workflows/ci.yml | 22 ---------------------- 1 file changed, 22 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index adf7ba00..88500940 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -4,7 +4,6 @@ on: push: branches: - master - - cd-release pull_request: branches: - master @@ -43,27 +42,6 @@ jobs: node build-scripts release --confirm env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - name: Deploy - if: false - run: | - if git log --format=%B -n 1 | egrep '^:bookmark: v[0-9]+\.[0-9]+\.[0-9]+' - then - if [ -n "$GH_APP_CREDENTIALS_TOKEN" ] - then - GH_TOKEN="$(npx obtain-github-app-installation-access-token ci $GH_APP_CREDENTIALS_TOKEN)" - echo "::add-mask::$GH_TOKEN" - git remote add www https://akibot:$GH_TOKEN@github.com/bemusic/bemusic.github.io.git - git config --global user.email "aki@spacet.me" - git config --global user.name "Aki running on GitHub Actions" - node build-scripts deploy - else - echo "GH_APP_CREDENTIALS_TOKEN is not set, skipped" - fi - else - echo 'Not a release commit, skipped!' - fi - env: - GH_APP_CREDENTIALS_TOKEN: ${{ secrets.GH_APP_CREDENTIALS_TOKEN }} - name: Upload artifact if: always() uses: actions/upload-artifact@v3 From c0661f5f567db1f8adacff988a58c6914222040a Mon Sep 17 00:00:00 2001 From: dtinth on MBP M1 Date: Fri, 30 Dec 2022 13:45:16 +0700 Subject: [PATCH 07/16] Remove pre-release flag --- bemuse/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bemuse/package.json b/bemuse/package.json index 1899bd60..818a48ca 100644 --- a/bemuse/package.json +++ b/bemuse/package.json @@ -1,6 +1,6 @@ { "name": "bemuse", - "version": "53.2.0-pre.1", + "version": "53.2.0", "description": "BEAT☆MUSIC☆SEQUENCE, a web-based music game of the future", "private": true, "browserslist": [ From cd2698542a0a3df5e4fbf88a2aef1a8319dbe084 Mon Sep 17 00:00:00 2001 From: dtinth on MBP M1 Date: Fri, 30 Dec 2022 13:55:30 +0700 Subject: [PATCH 08/16] Add helpful link to create a changelog entry --- .github/workflows/ci.yml | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 88500940..a6e0c70e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -151,3 +151,36 @@ jobs: - uses: codecov/codecov-action@v2 with: token: ${{ secrets.CODECOV_TOKEN }} + changelog: + runs-on: ubuntu-latest + if: github.event_name == 'pull_request' + env: + AUTHOR: ${{ github.event.pull_request.user.login }} + PR: ${{ github.event.pull_request.number }} + PR_NEW_FILE_URL: + https://github.com/${{ github.event.pull_request.head.repo.full_name + }}/new/${{ github.event.pull_request.head.ref }} + steps: + - name: Generate changelog file + uses: actions/github-script@v6 + with: + script: | + const path = `changelog/pr-${process.env.PR}.md` + const contents = [ + '---' + 'author: ' + process.env.AUTHOR, + 'category: feature/internals/bugfix/improvement', + 'type: major/minor/patch', + 'pr: ' + process.env.PR, + '---', + '', + '(Write your changelog entry here)', + ].join('\n') + const url = `${process.env.PR_NEW_FILE_URL}?filename=${encodeURIComponent(path)}&value=${encodeURIComponent(contents)}` + const summary = `[Click here to create a changelog entry.](${url})` + require('fs').appendFileSync(process.env.GITHUB_STEP_SUMMARY, summary) + '# Changelog', + '', + `To add a changelog entry, please [create a new file](${url}) with the following contents:`, + ] + require('fs').appendFileSync(process.env.GITHUB_STEP_SUMMARY, summary) From 13f63829baec3c80d43796afbb1a5bd342f7d635 Mon Sep 17 00:00:00 2001 From: dtinth on MBP M1 Date: Fri, 30 Dec 2022 13:57:16 +0700 Subject: [PATCH 09/16] Fix --- .github/workflows/ci.yml | 2 +- website/docs/workflows.md | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a6e0c70e..94d313c8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -167,7 +167,7 @@ jobs: script: | const path = `changelog/pr-${process.env.PR}.md` const contents = [ - '---' + '---', 'author: ' + process.env.AUTHOR, 'category: feature/internals/bugfix/improvement', 'type: major/minor/patch', diff --git a/website/docs/workflows.md b/website/docs/workflows.md index 6fb1d555..7385e119 100644 --- a/website/docs/workflows.md +++ b/website/docs/workflows.md @@ -23,9 +23,9 @@ pr: (Describe the change here) ``` -- `author`: GitHub username of the author. +- `author`: GitHub username of the author. (Can be an array if there are multiple authors.) - `category`: One of `feature`, `internals`, `bugfix`, `improvement`. -- `pr`: Pull request number. +- `pr`: Pull request number. (Can be an array if there are multiple PRs.) - `type`: One of `major`, `minor`, `patch`. If not specified, it will be a `patch` release. ## Merging PRs From 167a1a1c534a6505dc1ff9162ab9f07e0fef023a Mon Sep 17 00:00:00 2001 From: dtinth on MBP M1 Date: Fri, 30 Dec 2022 13:58:42 +0700 Subject: [PATCH 10/16] Print URL --- .github/workflows/ci.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 94d313c8..1c1c4f44 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -184,3 +184,10 @@ jobs: `To add a changelog entry, please [create a new file](${url}) with the following contents:`, ] require('fs').appendFileSync(process.env.GITHUB_STEP_SUMMARY, summary) + console.log('To create a changelog entry, create a file at', path) + console.log('') + console.log('Example contents:') + console.log('') + console.log(contents) + console.log('') + console.log(url) From d9880291315bbdaee6d65a438f130c003acd3fbc Mon Sep 17 00:00:00 2001 From: dtinth on MBP M1 Date: Fri, 30 Dec 2022 13:59:31 +0700 Subject: [PATCH 11/16] Fix syntax --- .github/workflows/ci.yml | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1c1c4f44..ceb1f569 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -177,12 +177,8 @@ jobs: '(Write your changelog entry here)', ].join('\n') const url = `${process.env.PR_NEW_FILE_URL}?filename=${encodeURIComponent(path)}&value=${encodeURIComponent(contents)}` - const summary = `[Click here to create a changelog entry.](${url})` require('fs').appendFileSync(process.env.GITHUB_STEP_SUMMARY, summary) - '# Changelog', - '', - `To add a changelog entry, please [create a new file](${url}) with the following contents:`, - ] + const summary = `[Click here to create a changelog entry.](${url})` require('fs').appendFileSync(process.env.GITHUB_STEP_SUMMARY, summary) console.log('To create a changelog entry, create a file at', path) console.log('') From 33125f8d7c46f91365cd750a304937c5d98bb9ac Mon Sep 17 00:00:00 2001 From: dtinth on MBP M1 Date: Fri, 30 Dec 2022 14:01:20 +0700 Subject: [PATCH 12/16] Fix script --- .github/workflows/ci.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ceb1f569..6141a62c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -177,7 +177,6 @@ jobs: '(Write your changelog entry here)', ].join('\n') const url = `${process.env.PR_NEW_FILE_URL}?filename=${encodeURIComponent(path)}&value=${encodeURIComponent(contents)}` - require('fs').appendFileSync(process.env.GITHUB_STEP_SUMMARY, summary) const summary = `[Click here to create a changelog entry.](${url})` require('fs').appendFileSync(process.env.GITHUB_STEP_SUMMARY, summary) console.log('To create a changelog entry, create a file at', path) From 1df8de82eabf7ba6a63ef4dfbd3bb324916a5473 Mon Sep 17 00:00:00 2001 From: Thai Pangsakulyanont Date: Fri, 30 Dec 2022 14:04:46 +0700 Subject: [PATCH 13/16] Create pr-803.md --- changelog/pr-803.md | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 changelog/pr-803.md diff --git a/changelog/pr-803.md b/changelog/pr-803.md new file mode 100644 index 00000000..d633c212 --- /dev/null +++ b/changelog/pr-803.md @@ -0,0 +1,8 @@ +--- +author: dtinth +category: internals +type: minor +pr: 803 +--- + +Revamped the deployment pipeline to streamline [the release process](https://bemuse.ninja/project/docs/workflows/). From 2ec27ccb25dde0245716e20ab72d6f924020f857 Mon Sep 17 00:00:00 2001 From: dtinth on MBP M1 Date: Fri, 30 Dec 2022 14:05:27 +0700 Subject: [PATCH 14/16] Do not run prettier on changelog entry files (they will be prettified automatically) --- .prettierignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.prettierignore b/.prettierignore index 74e0df3a..65e53882 100644 --- a/.prettierignore +++ b/.prettierignore @@ -15,4 +15,5 @@ pnpm-lock.yaml yarn.lock package-lock.json shrinkwrap.json -**/*.md \ No newline at end of file +**/*.md +changelog/*.md \ No newline at end of file From a04b36cdf90aa33f90c5db449570a3805c62b760 Mon Sep 17 00:00:00 2001 From: dtinth on MBP M1 Date: Fri, 30 Dec 2022 14:07:52 +0700 Subject: [PATCH 15/16] Update docs --- website/docs/workflows.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/website/docs/workflows.md b/website/docs/workflows.md index 7385e119..503710e5 100644 --- a/website/docs/workflows.md +++ b/website/docs/workflows.md @@ -11,13 +11,14 @@ sidebar_label: Workflows ## Authoring change logs -For changes in the Bemuse game, create a changelog entry in the `changelog` folder. +For changes in the Bemuse game, create a Markdown in the `changelog` folder containing the changelog entry. Use the following front-matter: -```yaml +```markdown --- author: category: pr: +type: --- (Describe the change here) From 2e417dfca1545c24623e5ac8e89ace070e0542cf Mon Sep 17 00:00:00 2001 From: dtinth on MBP M1 Date: Fri, 30 Dec 2022 14:09:30 +0700 Subject: [PATCH 16/16] Do not deploy if no new tag --- .github/workflows/ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6141a62c..334a49eb 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -54,6 +54,7 @@ jobs: uses: ./.github/workflows/deploy-production.yml needs: build secrets: inherit + if: needs.build.outputs.released-tag with: tag: ${{ needs.build.outputs.released-tag }} e2e: