From 124ee84d1fe733aa4abbd2d41542c3d8e24d23fd Mon Sep 17 00:00:00 2001 From: Felipe Suero Date: Thu, 27 Apr 2023 10:23:36 -0400 Subject: [PATCH 1/8] Automate incrementing the version number --- .github/workflows/publish.yml | 25 ++++++++++++++++-------- scripts/workflows/increment-version.sh | 27 ++++++++++++++++++++++++++ 2 files changed, 44 insertions(+), 8 deletions(-) create mode 100644 scripts/workflows/increment-version.sh diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 17b4347..c16ac9c 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -7,7 +7,12 @@ on: inputs: version: required: true - description: "Version to bump `package.json` to (format: x.y.z)" + type: choice + description: "What type of release is this" + options: + - "major" + - "minor" + - "patch" jobs: create-release-pr: @@ -31,21 +36,25 @@ jobs: git config --global user.email "github-actions@github.com" git config --global user.name "GitHub Actions" - git checkout -b release/${{ inputs.version }} + NEW_VERSION=$(./scripts/workflows/increment-version.sh ${{ inputs.version }}) - npx lerna version ${{ inputs.version }} --yes --no-push --no-git-tag-version --force-publish + git checkout -b release/$NEW_VERSION + + npx lerna version $NEW_VERSION --yes --no-push --no-git-tag-version --force-publish git add **/package.json package-lock.json lerna.json - git commit -m "Release extension version ${{ inputs.version }}" + git commit -m "Release extension version $NEW_VERSION" - git push --set-upstream origin release/${{ inputs.version }} + git push --set-upstream origin release/$NEW_VERSION + + echo "new_version=$NEW_VERSION" >> $GITHUB_ENV - name: Create PR run: | gh pr create \ - --title "Release version ${{ inputs.version }}" \ - --body "Release version ${{ inputs.version }}" \ + --title "Release version ${{ env.new_version }}" \ + --body "Release version ${{ env.new_version }}" \ --base main \ - --head release/${{ inputs.version }} + --head release/${{ env.new_version }} env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/scripts/workflows/increment-version.sh b/scripts/workflows/increment-version.sh new file mode 100644 index 0000000..fe95efc --- /dev/null +++ b/scripts/workflows/increment-version.sh @@ -0,0 +1,27 @@ +#!/bin/bash + +VERSION=$(cat package.json | jq -r '.version') + +echo "Current version: $VERSION" +echo "Incrementing $1 version" + +MAJOR=$(echo $VERSION | cut -d. -f1) +MINOR=$(echo $VERSION | cut -d. -f2) +PATCH=$(echo $VERSION | cut -d. -f3) + +if [ "$1" == "major" ]; then + MAJOR=$((MAJOR+1)) + MINOR=0 + PATCH=0 +elif [ "$1" == "minor" ]; then + MINOR=$((MINOR+1)) + PATCH=0 +elif [ "$1" == "patch" ]; then + PATCH=$((PATCH+1)) +else + echo "Invalid version type. Use 'major', 'minor' or 'patch'" + exit 1 +fi + +NEW_VERSION="$MAJOR.$MINOR.$PATCH" +echo $NEW_VERSION From 58bf3b35ccee7ac6ff3682d71774318e85fbe491 Mon Sep 17 00:00:00 2001 From: Felipe Suero Date: Thu, 27 Apr 2023 10:25:40 -0400 Subject: [PATCH 2/8] chmod --- scripts/workflows/increment-version.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 scripts/workflows/increment-version.sh diff --git a/scripts/workflows/increment-version.sh b/scripts/workflows/increment-version.sh old mode 100644 new mode 100755 From 8bc0c5636e28642d446a23b50469a13a70a4e562 Mon Sep 17 00:00:00 2001 From: Felipe Suero Date: Thu, 27 Apr 2023 10:28:01 -0400 Subject: [PATCH 3/8] draw from lerna --- .github/workflows/publish.yml | 2 +- scripts/workflows/increment-version.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index c16ac9c..69a25e1 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -1,6 +1,6 @@ name: Create release PR -run-name: Create release PR for v${{ github.event.inputs.version }} +run-name: Create release PR for new v${{ github.event.inputs.version }} version on: workflow_dispatch: diff --git a/scripts/workflows/increment-version.sh b/scripts/workflows/increment-version.sh index fe95efc..b915542 100755 --- a/scripts/workflows/increment-version.sh +++ b/scripts/workflows/increment-version.sh @@ -1,6 +1,6 @@ #!/bin/bash -VERSION=$(cat package.json | jq -r '.version') +VERSION=$(cat lerna.json | jq -r '.version') echo "Current version: $VERSION" echo "Incrementing $1 version" From 2795997f4c1ecda30a03d5c1b3d30910c287fdc9 Mon Sep 17 00:00:00 2001 From: Felipe Suero Date: Fri, 28 Apr 2023 12:53:31 -0400 Subject: [PATCH 4/8] minor fixes --- .github/workflows/publish.yml | 2 +- {scripts => script}/workflows/increment-version.sh | 3 --- 2 files changed, 1 insertion(+), 4 deletions(-) rename {scripts => script}/workflows/increment-version.sh (88%) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 69a25e1..19a3ac0 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -1,6 +1,6 @@ name: Create release PR -run-name: Create release PR for new v${{ github.event.inputs.version }} version +run-name: Create release PR for new ${{ github.event.inputs.version }} version on: workflow_dispatch: diff --git a/scripts/workflows/increment-version.sh b/script/workflows/increment-version.sh similarity index 88% rename from scripts/workflows/increment-version.sh rename to script/workflows/increment-version.sh index b915542..243fa8d 100755 --- a/scripts/workflows/increment-version.sh +++ b/script/workflows/increment-version.sh @@ -2,9 +2,6 @@ VERSION=$(cat lerna.json | jq -r '.version') -echo "Current version: $VERSION" -echo "Incrementing $1 version" - MAJOR=$(echo $VERSION | cut -d. -f1) MINOR=$(echo $VERSION | cut -d. -f2) PATCH=$(echo $VERSION | cut -d. -f3) From b04e5db100292ce956a3846022fa1e49a9945276 Mon Sep 17 00:00:00 2001 From: Felipe Suero Date: Fri, 28 Apr 2023 12:55:00 -0400 Subject: [PATCH 5/8] save files --- .github/workflows/publish.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 19a3ac0..75bd962 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -36,7 +36,7 @@ jobs: git config --global user.email "github-actions@github.com" git config --global user.name "GitHub Actions" - NEW_VERSION=$(./scripts/workflows/increment-version.sh ${{ inputs.version }}) + NEW_VERSION=$(./script/workflows/increment-version.sh ${{ inputs.version }}) git checkout -b release/$NEW_VERSION From 8f4080074b57014af3b6e085a18e7c93a34d0cd2 Mon Sep 17 00:00:00 2001 From: Felipe Suero Date: Mon, 1 May 2023 10:05:19 -0400 Subject: [PATCH 6/8] pin dependencies --- .github/workflows/publish.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 75bd962..0fd5ec3 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -25,9 +25,9 @@ jobs: pull-requests: write steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab - - uses: actions/setup-node@v3 + - uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c with: node-version: "16" From e292f8ca51fc5c0482685a36bd2582952aab4bb8 Mon Sep 17 00:00:00 2001 From: Felipe Suero Date: Mon, 1 May 2023 10:10:52 -0400 Subject: [PATCH 7/8] pin all the things --- .github/workflows/buildtest.yml | 4 ++-- .github/workflows/release.yml | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/buildtest.yml b/.github/workflows/buildtest.yml index f80be99..7fe5644 100644 --- a/.github/workflows/buildtest.yml +++ b/.github/workflows/buildtest.yml @@ -11,9 +11,9 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab - name: Use Node.js 16.15 - uses: actions/setup-node@v3 + uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c with: node-version: 16.15 cache: 'npm' diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 1139c4f..0f13b4f 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -24,10 +24,10 @@ jobs: contents: read steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab - name: Check if version has changed id: check-version - uses: actions/github-script@v6 + uses: actions/github-script@d7906e4ad0b1822421a7e6a35d5ca353c962f410 with: script: | const version = '${{ inputs.version }}' || require('./lerna.json').version; @@ -65,9 +65,9 @@ jobs: PKG_VERSION: "" # will be set in the workflow steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab - - uses: actions/setup-node@v3 + - uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c with: node-version: 16.x cache: "npm" @@ -80,7 +80,7 @@ jobs: - run: npm ci - name: Create release - uses: actions/github-script@v6 + uses: actions/github-script@d7906e4ad0b1822421a7e6a35d5ca353c962f410 with: script: | const fs = require("fs"); From d47636092a014a33958eab1d225bff6b9e9658fe Mon Sep 17 00:00:00 2001 From: Felipe Suero Date: Mon, 1 May 2023 10:15:24 -0400 Subject: [PATCH 8/8] don't pin actions stuff --- .github/workflows/buildtest.yml | 4 ++-- .github/workflows/publish.yml | 4 ++-- .github/workflows/release.yml | 10 +++++----- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/workflows/buildtest.yml b/.github/workflows/buildtest.yml index 7fe5644..f80be99 100644 --- a/.github/workflows/buildtest.yml +++ b/.github/workflows/buildtest.yml @@ -11,9 +11,9 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab + - uses: actions/checkout@v3 - name: Use Node.js 16.15 - uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c + uses: actions/setup-node@v3 with: node-version: 16.15 cache: 'npm' diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 0fd5ec3..75bd962 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -25,9 +25,9 @@ jobs: pull-requests: write steps: - - uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab + - uses: actions/checkout@v3 - - uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c + - uses: actions/setup-node@v3 with: node-version: "16" diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 0f13b4f..1139c4f 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -24,10 +24,10 @@ jobs: contents: read steps: - - uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab + - uses: actions/checkout@v3 - name: Check if version has changed id: check-version - uses: actions/github-script@d7906e4ad0b1822421a7e6a35d5ca353c962f410 + uses: actions/github-script@v6 with: script: | const version = '${{ inputs.version }}' || require('./lerna.json').version; @@ -65,9 +65,9 @@ jobs: PKG_VERSION: "" # will be set in the workflow steps: - - uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab + - uses: actions/checkout@v3 - - uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c + - uses: actions/setup-node@v3 with: node-version: 16.x cache: "npm" @@ -80,7 +80,7 @@ jobs: - run: npm ci - name: Create release - uses: actions/github-script@d7906e4ad0b1822421a7e6a35d5ca353c962f410 + uses: actions/github-script@v6 with: script: | const fs = require("fs");