From de61b7340840c2147365201d703457f57178f81c Mon Sep 17 00:00:00 2001 From: Ice Lam Date: Sat, 30 Oct 2021 16:35:49 +0800 Subject: [PATCH] ci: update ci to use latest ubuntu image --- .github/workflows/ci.yml | 2 +- .github/workflows/rebase.yml | 2 +- .github/workflows/release.yml | 18 +++++++++++++++--- package.json | 1 - scripts/extractLatestChangeLog.js | 16 ---------------- 5 files changed, 17 insertions(+), 22 deletions(-) delete mode 100644 scripts/extractLatestChangeLog.js diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fbb328e..cafb1ec 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,7 +13,7 @@ on: jobs: test: name: Test - runs-on: ubuntu-18.04 + runs-on: ubuntu-latest strategy: matrix: node-version: [12.x, 14.x, 16.x] diff --git a/.github/workflows/rebase.yml b/.github/workflows/rebase.yml index 6920a31..155819d 100644 --- a/.github/workflows/rebase.yml +++ b/.github/workflows/rebase.yml @@ -6,7 +6,7 @@ jobs: rebase: name: Rebase if: github.event.issue.pull_request != '' && contains(github.event.comment.body, '/rebase') - runs-on: ubuntu-18.04 + runs-on: ubuntu-latest steps: - name: Checkout the latest code uses: actions/checkout@main diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 9cd2999..7fab01e 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -7,7 +7,7 @@ on: jobs: release: name: Create release - runs-on: ubuntu-18.04 + runs-on: ubuntu-latest steps: - name: Checkout repo @@ -15,11 +15,23 @@ jobs: - name: Setup Node.js version uses: actions/setup-node@main with: - node-version: '12.16.1' + node-version: 14.x - name: Generate release body run: | - yarn extract-latest-change-log + npx rexreplace "(#+ \[\d+\.\d+\.\d+].*?)#+ \[?\d+\.\d+\.\d+]?" "_" -s -M -G -m -o "CHANGELOG.md" > RELEASE_BODY.md + result=$(cat RELEASE_BODY.md) + + if [[ $? != 0 ]]; then + echo "Command failed." + exit 1; + elif [[ $result ]]; then + echo "Release body generated." + else + echo "This is the first release, using different command to generate release body." + npx rexreplace "(#+ \[?\d+\.\d+\.\d+]?.*)" "_" -s -M -G -m -o "CHANGELOG.md" > RELEASE_BODY.md + fi + - name: Create release id: create-release uses: actions/create-release@v1 diff --git a/package.json b/package.json index 5b3775a..a2990fe 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,6 @@ "prepare": "husky install && install-peers", "first-release": "npx standard-version --commit-all --tag-prefix v --first-release", "release": "npx standard-version --commit-all --tag-prefix v", - "extract-latest-change-log": "node scripts/extractLatestChangeLog.js", "test": "jest --verbose --watchAll --config ./jest.config.js", "test:ci": "yarn test --ci --watchAll=false --runInBand --detectOpenHandles" }, diff --git a/scripts/extractLatestChangeLog.js b/scripts/extractLatestChangeLog.js deleted file mode 100644 index e36a49b..0000000 --- a/scripts/extractLatestChangeLog.js +++ /dev/null @@ -1,16 +0,0 @@ -const fs = require('fs').promises; -const path = require('path'); - -const BASE_DIR = path.join(__dirname, '..'); -const CHANGELOG_PATH = path.join(BASE_DIR, 'CHANGELOG.md'); -const RELEASE_BODY_PATH = path.join(BASE_DIR, 'RELEASE_BODY.md'); - -(async () => { - try { - const file = await fs.readFile(CHANGELOG_PATH, 'utf8'); - const updated = /(#+ \[\d+\.\d+\.\d+].*?)#+ \[?\d+\.\d+\.\d+]?/s.exec(file); - await fs.writeFile(RELEASE_BODY_PATH, updated[1]); - } catch (error) { - console.error(error); - } -})();