From 56941ca2077ab54d683c40ff7a6f735ea1dfc316 Mon Sep 17 00:00:00 2001 From: Jonathon Terry <10217028+Maverick1872@users.noreply.github.com> Date: Sun, 1 Jan 2023 17:52:21 -0500 Subject: [PATCH 01/13] feat: scaffold release workflows --- .github/workflows/release-sdk.yaml | 75 ++++++++++++++++++++++++++++++ .github/workflows/tag-release.yaml | 59 +++++++++++++++++++++++ 2 files changed, 134 insertions(+) create mode 100644 .github/workflows/release-sdk.yaml create mode 100644 .github/workflows/tag-release.yaml diff --git a/.github/workflows/release-sdk.yaml b/.github/workflows/release-sdk.yaml new file mode 100644 index 000000000..31d538bec --- /dev/null +++ b/.github/workflows/release-sdk.yaml @@ -0,0 +1,75 @@ +name: "Create release PR" + +on: + workflow_dispatch: + inputs: + branch: + description: "What branch should SDK be built from?" + required: true + default: "develop" + type: string + versionType: + description: "What kind of version bump is this?" + required: true + type: choice + options: + - major + - minor + - patch + - premajor + - preminor + - prepatch + - prerelease + dryRun: + description: "Should publish be a dry run?" + required: false + default: false + type: boolean + +jobs: + version-bump: + name: Bump version + runs-on: ubuntu-latest + steps: + - name: Checkout Source + uses: actions/checkout@v3 + with: + ref: ${{ inputs.branch }} + - name: Setup Node + uses: actions/setup-node@v3 + with: + node-version: 16 + + - name: Install dependencies + run: npm ci + + - name: Bump version (${{ inputs.versionType }}) + if: ${{ !startsWith(inputs.versionType, 'pre') }} + run: | + ACTOR_ID=$(curl -X GET ${{ github.api_url }}/users/${{ github.actor }} | jq -r '.id') + ACTOR_EMAIL="$ACTOR_ID+${{ github.actor }}@users.noreply.github.com" + ACTOR_NAME=$(curl -X GET ${{ github.api_url }}/users/${{ github.actor }} | jq -r '.name') + SHORT_SHA=$(echo ${{ github.sha }} | cut -c-7) + VERSION=$(npm version ${{ inputs.versionType }} ${{ startsWith(inputs.versionType, 'pre') && '--preid=ci-$SHORT_SHA' || '' }} --no-git-tag-version) + + echo "VERSION=$VERSION" >> $GITHUB_ENV + + git config --global user.name 'github-actions[bot]' + git config --global user.email 'github-actions[bot]@users.noreply.github.com' + git add package.json package-lock.json + git commit -m "Bumping SDK - ${{ env.VERSION }}" -m "" -m "" -m "Co-authored-by: $ACTOR_NAME <$ACTOR_EMAIL>" + + - name: Publish package ${{ inputs.dryRun && '(Dry Run)' || '' }} + if: ${{ startsWith(inputs.versionType, 'pre') }} + run: npm publish ${{ inputs.dryRun && '--dry-run' || '' }} + env: + NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}} + + - name: Open Pull Request + if: ${{ !inputs.dryRun && !startsWith(inputs.versionType, 'pre') }} + uses: peter-evans/create-pull-request@v4 + with: + delete-branch: true + branch: "release/sdk/${{ env.VERSION }}" + title: "Release SDK: ${{ env.VERSION }}" + labels: "SDK, Release, Automated" diff --git a/.github/workflows/tag-release.yaml b/.github/workflows/tag-release.yaml new file mode 100644 index 000000000..da039df3a --- /dev/null +++ b/.github/workflows/tag-release.yaml @@ -0,0 +1,59 @@ +name: "Tag & Publish Release" + +on: + pull_request: + types: + - closed + +jobs: + tag-commit: + name: Tag release commit + if: ${{ github.event.pull_request.merged == true }} + env: + PR_BRANCH: ${{ github.event.pull_request.head.ref }} + runs-on: ubuntu-latest + outputs: + TAG: ${{ steps.tag-operation.outputs.TAG_NAME }} + steps: + - name: Checkout Source + uses: actions/checkout@v3 + + - name: Tag commit with version + id: tag-operation + if: ${{ contains( env.PR_BRANCH, 'release/sdk' )}} + run: | + echo "TAG_NAME=sdk-${PR_BRANCH##*/}" >> $GITHUB_OUTPUT + git tag ${{ env.TAG_NAME }} + git push origin ${{ env.TAG_NAME }} + + create-release: + needs: tag-commit + name: Create Release + runs-on: ubuntu-latest + env: + TAG: ${{ needs.tag-commit.outputs.TAG }} + steps: + - name: Checkout Source + uses: actions/checkout@v3 + + - name: Create release from tag + uses: ncipollo/release-action@v1.12.0 + with: + makeLatest: true + tag: ${{ env.TAG }} + name: ${{ env.TAG }} + generateReleaseNotes: true + + publish-version: + needs: tag-commit + name: Publish Version + runs-on: ubuntu-latest + steps: + - name: Checkout Source + uses: actions/checkout@v3 + + - name: Publish package + env: + NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}} + # run: npm publish + run: echo "publishing new version" From e83ef1e488a0ecd6535644829a2b487c2d1c1164 Mon Sep 17 00:00:00 2001 From: Jonathon Terry <10217028+Maverick1872@users.noreply.github.com> Date: Sat, 4 Feb 2023 08:20:26 -0700 Subject: [PATCH 02/13] feat: improve release workflows --- .github/workflows/ci.yml | 8 ++- .../{release-sdk.yaml => create-release.yml} | 55 ++++++++------ .github/workflows/release-tag.yml | 41 +++++++++++ .github/workflows/tag-release.yaml | 59 --------------- .github/workflows/tag-release.yml | 71 +++++++++++++++++++ 5 files changed, 153 insertions(+), 81 deletions(-) rename .github/workflows/{release-sdk.yaml => create-release.yml} (53%) create mode 100644 .github/workflows/release-tag.yml delete mode 100644 .github/workflows/tag-release.yaml create mode 100644 .github/workflows/tag-release.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4a5101ae2..b6cdbc648 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -3,11 +3,9 @@ name: CI Checks on: pull_request: branches: - - main - master push: branches: - - main - master permissions: @@ -31,18 +29,24 @@ jobs: - uses: actions/setup-node@v3 with: node-version: ${{ matrix.node }} + - name: Install Dependencies run: npm clean-install + - name: Lint run: npm run lint + - name: Integration Tests run: npm run test:integration + - name: Test Coverage run: npm run test:coverage + - name: Report test coverage to Coveralls.io if: matrix.node == '16' uses: coverallsapp/github-action@master with: github-token: ${{ secrets.GITHUB_TOKEN }} + - name: TypeScript Test run: npx --package typescript tsc --project test diff --git a/.github/workflows/release-sdk.yaml b/.github/workflows/create-release.yml similarity index 53% rename from .github/workflows/release-sdk.yaml rename to .github/workflows/create-release.yml index 31d538bec..da016bd3c 100644 --- a/.github/workflows/release-sdk.yaml +++ b/.github/workflows/create-release.yml @@ -1,12 +1,12 @@ -name: "Create release PR" +name: "Create Release PR" on: workflow_dispatch: inputs: branch: - description: "What branch should SDK be built from?" + description: "What branch should the SDK be built from?" required: true - default: "develop" + default: "main" type: string versionType: description: "What kind of version bump is this?" @@ -27,49 +27,64 @@ on: type: boolean jobs: - version-bump: - name: Bump version + generate-sdk: + name: Generate SDK runs-on: ubuntu-latest steps: - name: Checkout Source uses: actions/checkout@v3 with: ref: ${{ inputs.branch }} + - name: Setup Node uses: actions/setup-node@v3 + env: + NODE_AUTH_TOKEN: ${{secrets.BOT_PAT}} with: node-version: 16 + cache: 'npm' - name: Install dependencies - run: npm ci + run: npm ci --ignore-scripts - - name: Bump version (${{ inputs.versionType }}) + # Commit version if it's not a pre-release version + - name: Commit OpenApi JSON and version bump if: ${{ !startsWith(inputs.versionType, 'pre') }} + env: + GH_TOKEN: ${{secrets.GITHUB_TOKEN}} + ACTOR: ${{ github.actor }} run: | - ACTOR_ID=$(curl -X GET ${{ github.api_url }}/users/${{ github.actor }} | jq -r '.id') - ACTOR_EMAIL="$ACTOR_ID+${{ github.actor }}@users.noreply.github.com" - ACTOR_NAME=$(curl -X GET ${{ github.api_url }}/users/${{ github.actor }} | jq -r '.name') + ACTOR_INFO=$(gh api /users/$ACTOR) + ACTOR_ID=$(echo $ACTOR_INFO | jq -r '.id') + ACTOR_EMAIL="$ACTOR_ID+$ACTOR@users.noreply.github.com" + ACTOR_NAME=$(echo $ACTOR_INFO | jq -r '.name') + SHORT_SHA=$(echo ${{ github.sha }} | cut -c-7) VERSION=$(npm version ${{ inputs.versionType }} ${{ startsWith(inputs.versionType, 'pre') && '--preid=ci-$SHORT_SHA' || '' }} --no-git-tag-version) - echo "VERSION=$VERSION" >> $GITHUB_ENV - git config --global user.name 'github-actions[bot]' - git config --global user.email 'github-actions[bot]@users.noreply.github.com' - git add package.json package-lock.json - git commit -m "Bumping SDK - ${{ env.VERSION }}" -m "" -m "" -m "Co-authored-by: $ACTOR_NAME <$ACTOR_EMAIL>" + git config --global user.name '' + git config --global user.email '' + git add + git commit -m "Bumping Package - $VERSION" \ + -m "" \ + -m "" \ + -m "Co-authored-by: $ACTOR_NAME <$ACTOR_EMAIL>" - - name: Publish package ${{ inputs.dryRun && '(Dry Run)' || '' }} + # If version bump is a pre-release just go ahead and publish (dry run or otherwise) + - name: Publish pre-release package ${{ inputs.dryRun && '(Dry Run)' || '' }} if: ${{ startsWith(inputs.versionType, 'pre') }} - run: npm publish ${{ inputs.dryRun && '--dry-run' || '' }} env: NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}} + run: npm publish ${{ inputs.dryRun && '--dry-run' || '' }} + # If version bump is not a pre-release and not a dry run, create release PR for human review - name: Open Pull Request if: ${{ !inputs.dryRun && !startsWith(inputs.versionType, 'pre') }} uses: peter-evans/create-pull-request@v4 with: + token: ${{ secrets.BOT_PAT }} delete-branch: true - branch: "release/sdk/${{ env.VERSION }}" - title: "Release SDK: ${{ env.VERSION }}" - labels: "SDK, Release, Automated" + branch: "release/${{ env.VERSION }}" + title: "Release: ${{ env.VERSION }}" + labels: "release, automated" diff --git a/.github/workflows/release-tag.yml b/.github/workflows/release-tag.yml new file mode 100644 index 000000000..60a9a2e22 --- /dev/null +++ b/.github/workflows/release-tag.yml @@ -0,0 +1,41 @@ +name: "Generate & Ship Release #ShipIt" + +on: + push: + tags: + - release-** +jobs: + create-github-release: + name: Create GitHub Release + runs-on: ubuntu-latest + steps: + - name: Checkout Source + uses: actions/checkout@v3 + + - name: Create release from tag + uses: ncipollo/release-action@v1.12.0 + with: + makeLatest: false + generateReleaseNotes: false + + publish-sdk-version: + name: Publish SDK Version + if: contains(github.ref, 'sdk') + runs-on: ubuntu-latest + steps: + - name: Checkout Source + uses: actions/checkout@v3 + + - name: Setup Node + uses: actions/setup-node@v3 + env: + NODE_AUTH_TOKEN: ${{secrets.BOT_PAT}} + with: + node-version: 16 + cache: 'npm' + + - name: Prepare for publish + run: npm ci + + - name: Publish package + run: npm publish diff --git a/.github/workflows/tag-release.yaml b/.github/workflows/tag-release.yaml deleted file mode 100644 index da039df3a..000000000 --- a/.github/workflows/tag-release.yaml +++ /dev/null @@ -1,59 +0,0 @@ -name: "Tag & Publish Release" - -on: - pull_request: - types: - - closed - -jobs: - tag-commit: - name: Tag release commit - if: ${{ github.event.pull_request.merged == true }} - env: - PR_BRANCH: ${{ github.event.pull_request.head.ref }} - runs-on: ubuntu-latest - outputs: - TAG: ${{ steps.tag-operation.outputs.TAG_NAME }} - steps: - - name: Checkout Source - uses: actions/checkout@v3 - - - name: Tag commit with version - id: tag-operation - if: ${{ contains( env.PR_BRANCH, 'release/sdk' )}} - run: | - echo "TAG_NAME=sdk-${PR_BRANCH##*/}" >> $GITHUB_OUTPUT - git tag ${{ env.TAG_NAME }} - git push origin ${{ env.TAG_NAME }} - - create-release: - needs: tag-commit - name: Create Release - runs-on: ubuntu-latest - env: - TAG: ${{ needs.tag-commit.outputs.TAG }} - steps: - - name: Checkout Source - uses: actions/checkout@v3 - - - name: Create release from tag - uses: ncipollo/release-action@v1.12.0 - with: - makeLatest: true - tag: ${{ env.TAG }} - name: ${{ env.TAG }} - generateReleaseNotes: true - - publish-version: - needs: tag-commit - name: Publish Version - runs-on: ubuntu-latest - steps: - - name: Checkout Source - uses: actions/checkout@v3 - - - name: Publish package - env: - NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}} - # run: npm publish - run: echo "publishing new version" diff --git a/.github/workflows/tag-release.yml b/.github/workflows/tag-release.yml new file mode 100644 index 000000000..645ce8c9f --- /dev/null +++ b/.github/workflows/tag-release.yml @@ -0,0 +1,71 @@ +name: "Tag Release Commit" + +on: + pull_request: + types: + - closed + branches: + - main + +jobs: + was_merged: + name: Was PR Merged? + runs-on: ubuntu-latest + outputs: + result: ${{ steps.merge_check.outputs.result }} + env: + PR_BRANCH: ${{ github.event.pull_request.head.ref }} + steps: + - id: merge_check + run: echo "result=${{ github.event.pull_request.merged == true }}" >> $GITHUB_OUTPUT + + is_release: + name: Is PR a release? + runs-on: ubuntu-latest + outputs: + result: ${{ steps.merge_check.outputs.result }} + env: + PR_BRANCH: ${{ github.event.pull_request.head.ref }} + steps: + - id: merge_check + run: echo "result=${{ contains( env.PR_BRANCH, 'release') }}" >> $GITHUB_OUTPUT + + tag-merge-commit: + name: Tag release merge commit + needs: + - was_merged + - is_release + if: ${{ needs.was_merged.outputs.result == 'true' }} && ${{ needs.is_release.result == 'true' }} + env: + PR_BRANCH: ${{ github.event.pull_request.head.ref }} + ACTOR_ID: ${{ github.event.pull_request.merged_by.id }} + MERGE_AT: ${{ github.event.pull_request.merged_at }} + MERGE_COMMIT_SHA: ${{ github.event.pull_request.merge_commit_sha }} + runs-on: ubuntu-latest + steps: + - name: Checkout Source + uses: actions/checkout@v3 + with: + token: ${{ secrets.BOT_PAT }} + + - name: Tag commit with version + env: + ACTOR: ${{ github.actor }} + GH_TOKEN: ${{secrets.GITHUB_TOKEN}} + run: | + ACTOR_INFO=$(gh api /users/$ACTOR) + ACTOR_ID=$(echo $ACTOR_INFO | jq -r '.id') + ACTOR_EMAIL="$ACTOR_ID+$ACTOR@users.noreply.github.com" + ACTOR_NAME=$(echo $ACTOR_INFO | jq -r '.name') + TAG_NAME=release-sdk-${PR_BRANCH##*/} + + git config --global user.name 'xirr-9000' + git config --global user.email '51422590+xirr-9000@users.noreply.github.com' + + git tag -a $TAG_NAME \ + -m "Automated Release $TAG_NAME" \ + -m "" \ + -m "" \ + -m "Merged By: $ACTOR_NAME <$ACTOR_EMAIL>" \ + -m "Merged At: $MERGED_AT" $MERGE_COMMIT_SHA + git push origin $TAG_NAME From e0c90f5546ad88cfa03f5fdb915071be9f1c17bd Mon Sep 17 00:00:00 2001 From: Jonathon Terry <10217028+Maverick1872@users.noreply.github.com> Date: Sat, 4 Feb 2023 08:22:19 -0700 Subject: [PATCH 03/13] chore: remove author placeholder --- .github/workflows/tag-release.yml | 4 ++-- test/unit/formats/errors.test.js | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/tag-release.yml b/.github/workflows/tag-release.yml index 645ce8c9f..4e9db877d 100644 --- a/.github/workflows/tag-release.yml +++ b/.github/workflows/tag-release.yml @@ -59,8 +59,8 @@ jobs: ACTOR_NAME=$(echo $ACTOR_INFO | jq -r '.name') TAG_NAME=release-sdk-${PR_BRANCH##*/} - git config --global user.name 'xirr-9000' - git config --global user.email '51422590+xirr-9000@users.noreply.github.com' + git config --global user.name '' + git config --global user.email '' git tag -a $TAG_NAME \ -m "Automated Release $TAG_NAME" \ diff --git a/test/unit/formats/errors.test.js b/test/unit/formats/errors.test.js index 400de910a..a2c950655 100644 --- a/test/unit/formats/errors.test.js +++ b/test/unit/formats/errors.test.js @@ -1,4 +1,6 @@ /* + - main + - main * errors.test.js: E2E Integration tests of `new Error()` handling * * (C) 2010 Charlie Robbins From 062edb3b2ce30162ecabd96e641cadd00034973b Mon Sep 17 00:00:00 2001 From: Jonathon Terry <10217028+Maverick1872@users.noreply.github.com> Date: Sat, 4 Feb 2023 08:32:56 -0700 Subject: [PATCH 04/13] fix: change references from main to master --- .github/workflows/create-release.yml | 2 +- .github/workflows/tag-release.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/create-release.yml b/.github/workflows/create-release.yml index da016bd3c..724c11a94 100644 --- a/.github/workflows/create-release.yml +++ b/.github/workflows/create-release.yml @@ -6,7 +6,7 @@ on: branch: description: "What branch should the SDK be built from?" required: true - default: "main" + default: "master" type: string versionType: description: "What kind of version bump is this?" diff --git a/.github/workflows/tag-release.yml b/.github/workflows/tag-release.yml index 4e9db877d..10d67855d 100644 --- a/.github/workflows/tag-release.yml +++ b/.github/workflows/tag-release.yml @@ -5,7 +5,7 @@ on: types: - closed branches: - - main + - master jobs: was_merged: From 4509a27ecb8d982e847d22df4a0509c2ddf07568 Mon Sep 17 00:00:00 2001 From: Jonathon Terry <10217028+Maverick1872@users.noreply.github.com> Date: Sat, 4 Feb 2023 08:36:25 -0700 Subject: [PATCH 05/13] chore: add additional node versions to test matrix --- .github/workflows/ci.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b6cdbc648..7f303e5cd 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -24,6 +24,8 @@ jobs: - 12 - 14 - 16 + - 18 + - 20 steps: - uses: actions/checkout@v3 - uses: actions/setup-node@v3 From f6b27e49359b1ddfb5272d00c64090a398382977 Mon Sep 17 00:00:00 2001 From: Jonathon Terry <10217028+Maverick1872@users.noreply.github.com> Date: Sat, 4 Feb 2023 08:43:10 -0700 Subject: [PATCH 06/13] chore: minor cleanup --- .github/workflows/ci.yml | 2 +- .github/workflows/create-release.yml | 5 +++-- .github/workflows/release-tag.yml | 8 ++++---- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7f303e5cd..d2b661456 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -33,7 +33,7 @@ jobs: node-version: ${{ matrix.node }} - name: Install Dependencies - run: npm clean-install + run: npm ci --ignore-scripts - name: Lint run: npm run lint diff --git a/.github/workflows/create-release.yml b/.github/workflows/create-release.yml index 724c11a94..786038244 100644 --- a/.github/workflows/create-release.yml +++ b/.github/workflows/create-release.yml @@ -48,7 +48,7 @@ jobs: run: npm ci --ignore-scripts # Commit version if it's not a pre-release version - - name: Commit OpenApi JSON and version bump + - name: Commit version bump if: ${{ !startsWith(inputs.versionType, 'pre') }} env: GH_TOKEN: ${{secrets.GITHUB_TOKEN}} @@ -72,6 +72,7 @@ jobs: -m "Co-authored-by: $ACTOR_NAME <$ACTOR_EMAIL>" # If version bump is a pre-release just go ahead and publish (dry run or otherwise) + # Do we have any interest in tagging pre-release versions? - name: Publish pre-release package ${{ inputs.dryRun && '(Dry Run)' || '' }} if: ${{ startsWith(inputs.versionType, 'pre') }} env: @@ -79,7 +80,7 @@ jobs: run: npm publish ${{ inputs.dryRun && '--dry-run' || '' }} # If version bump is not a pre-release and not a dry run, create release PR for human review - - name: Open Pull Request + - name: Open Release PR if: ${{ !inputs.dryRun && !startsWith(inputs.versionType, 'pre') }} uses: peter-evans/create-pull-request@v4 with: diff --git a/.github/workflows/release-tag.yml b/.github/workflows/release-tag.yml index 60a9a2e22..a70b6b55c 100644 --- a/.github/workflows/release-tag.yml +++ b/.github/workflows/release-tag.yml @@ -15,11 +15,11 @@ jobs: - name: Create release from tag uses: ncipollo/release-action@v1.12.0 with: - makeLatest: false - generateReleaseNotes: false + makeLatest: true + generateReleaseNotes: true publish-sdk-version: - name: Publish SDK Version + name: Publish Version if: contains(github.ref, 'sdk') runs-on: ubuntu-latest steps: @@ -35,7 +35,7 @@ jobs: cache: 'npm' - name: Prepare for publish - run: npm ci + run: npm ci --ignore-scripts - name: Publish package run: npm publish From 9ac20adda196c8031067c0c6026d5b0c3552e2e7 Mon Sep 17 00:00:00 2001 From: Jonathon Terry <10217028+Maverick1872@users.noreply.github.com> Date: Tue, 7 Feb 2023 18:14:51 -0700 Subject: [PATCH 07/13] chore: prevent non pre release variants and remove invalid version --- .github/workflows/ci.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d2b661456..f6ac3fa29 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -25,7 +25,6 @@ jobs: - 14 - 16 - 18 - - 20 steps: - uses: actions/checkout@v3 - uses: actions/setup-node@v3 From dc03501e5e8b407490976332ea88b7a10fb1e3b3 Mon Sep 17 00:00:00 2001 From: Jonathon Terry <10217028+Maverick1872@users.noreply.github.com> Date: Tue, 7 Feb 2023 18:15:17 -0700 Subject: [PATCH 08/13] chore: prevent non pre release variants and remove invalid version --- .github/workflows/create-release.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/create-release.yml b/.github/workflows/create-release.yml index 786038244..312fa15d5 100644 --- a/.github/workflows/create-release.yml +++ b/.github/workflows/create-release.yml @@ -13,9 +13,9 @@ on: required: true type: choice options: - - major - - minor - - patch +# - major +# - minor +# - patch - premajor - preminor - prepatch From 58f805b56fa7afa124429bda68bbc42b5887aa5a Mon Sep 17 00:00:00 2001 From: Jonathon Terry <10217028+Maverick1872@users.noreply.github.com> Date: Tue, 7 Feb 2023 18:44:37 -0700 Subject: [PATCH 09/13] revert: undo unintentional change --- test/unit/formats/errors.test.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/test/unit/formats/errors.test.js b/test/unit/formats/errors.test.js index a2c950655..400de910a 100644 --- a/test/unit/formats/errors.test.js +++ b/test/unit/formats/errors.test.js @@ -1,6 +1,4 @@ /* - - main - - main * errors.test.js: E2E Integration tests of `new Error()` handling * * (C) 2010 Charlie Robbins From f9d5d1e8cca58d6a3c4ae93d8c7aa19744e0b6fc Mon Sep 17 00:00:00 2001 From: Jonathon Terry <10217028+Maverick1872@users.noreply.github.com> Date: Thu, 9 Feb 2023 22:52:17 -0700 Subject: [PATCH 10/13] 3.8.3-0 --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index cd9ec6cf3..3a59ba4bd 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "winston", - "version": "3.8.2", + "version": "3.8.3-0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "winston", - "version": "3.8.2", + "version": "3.8.3-0", "license": "MIT", "dependencies": { "@colors/colors": "1.5.0", diff --git a/package.json b/package.json index 979f40bb4..d50dbaf8d 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "winston", "description": "A logger for just about everything.", - "version": "3.8.2", + "version": "3.8.3-0", "author": "Charlie Robbins ", "maintainers": [ "David Hyde " From 82d0932e55597e52e39e47d4548660405df4ce14 Mon Sep 17 00:00:00 2001 From: Jonathon Terry <10217028+Maverick1872@users.noreply.github.com> Date: Thu, 16 Feb 2023 22:39:56 -0700 Subject: [PATCH 11/13] major workflow interoperability improvements --- .github/workflows/create-release.yml | 112 ++++++++++++++++----------- .github/workflows/release-tag.yml | 12 +-- .github/workflows/tag-release.yml | 21 +++-- 3 files changed, 87 insertions(+), 58 deletions(-) diff --git a/.github/workflows/create-release.yml b/.github/workflows/create-release.yml index 312fa15d5..1f28a18bd 100644 --- a/.github/workflows/create-release.yml +++ b/.github/workflows/create-release.yml @@ -3,23 +3,22 @@ name: "Create Release PR" on: workflow_dispatch: inputs: - branch: - description: "What branch should the SDK be built from?" - required: true - default: "master" - type: string versionType: description: "What kind of version bump is this?" required: true type: choice options: -# - major -# - minor -# - patch + - major + - minor + - patch - premajor - preminor - prepatch - prerelease + baseBranch: + description: "What base branch should be used for this release?" + required: false + type: string dryRun: description: "Should publish be a dry run?" required: false @@ -27,65 +26,88 @@ on: type: boolean jobs: - generate-sdk: - name: Generate SDK + create-release: + name: Create Release runs-on: ubuntu-latest + env: + DEFAULT_BRANCH: ${{ github.event.repository.default_branch }} + ACTOR: ${{ github.actor }} steps: + - name: Get Auth Token + uses: tibdex/github-app-token@v1 + id: get_auth_token + with: + app_id: ${{ vars.RELEASE_OPS_APP_ID }} + private_key: ${{ secrets.RELEASE_OPS_PRIVATE_KEY }} + + - name: Define job env vars + env: + GH_TOKEN: ${{ steps.get_auth_token.outputs.token }} + run: | + isPR=$(gh api repos/${{ github.repository }}/pulls | jq -r '${{ format('.[].head.ref=="{0}"', inputs.baseBranch) }} // false' ) + ACTOR_INFO=$(gh api /users/${{ env.ACTOR }}) + ACTOR_ID=$(echo $ACTOR_INFO | jq -r '.id') + ACTOR_EMAIL="$ACTOR_ID+$ACTOR@users.noreply.github.com" + ACTOR_NAME=$(echo $ACTOR_INFO | jq -r '.name') + + echo "HAS_PR=$isPR" >> $GITHUB_ENV + echo "ACTOR_NAME=$ACTOR_NAME" >> $GITHUB_ENV + echo "ACTOR_EMAIL=$ACTOR_EMAIL" >> $GITHUB_ENV + - name: Checkout Source uses: actions/checkout@v3 with: - ref: ${{ inputs.branch }} + token: ${{ steps.get_auth_token.outputs.token }} + ref: ${{ inputs.baseBranch || env.DEFAULT_BRANCH }} - name: Setup Node uses: actions/setup-node@v3 - env: - NODE_AUTH_TOKEN: ${{secrets.BOT_PAT}} with: node-version: 16 - cache: 'npm' + registry-url: 'https://registry.npmjs.org' + scope: ${{ vars.NPM_SCOPE }} # If this is not an organization I have to specify this. - name: Install dependencies run: npm ci --ignore-scripts - # Commit version if it's not a pre-release version - - name: Commit version bump - if: ${{ !startsWith(inputs.versionType, 'pre') }} - env: - GH_TOKEN: ${{secrets.GITHUB_TOKEN}} - ACTOR: ${{ github.actor }} + - name: Bump Version (${{ inputs.versionType }}) run: | - ACTOR_INFO=$(gh api /users/$ACTOR) - ACTOR_ID=$(echo $ACTOR_INFO | jq -r '.id') - ACTOR_EMAIL="$ACTOR_ID+$ACTOR@users.noreply.github.com" - ACTOR_NAME=$(echo $ACTOR_INFO | jq -r '.name') - SHORT_SHA=$(echo ${{ github.sha }} | cut -c-7) - VERSION=$(npm version ${{ inputs.versionType }} ${{ startsWith(inputs.versionType, 'pre') && '--preid=ci-$SHORT_SHA' || '' }} --no-git-tag-version) - echo "VERSION=$VERSION" >> $GITHUB_ENV + VERSION=$(npm version ${{ inputs.versionType }} ${{ startsWith(inputs.versionType, 'pre') && '--preid=RC' || '' }} --no-git-tag-version) + echo "VERSION=${VERSION%-*}" >> $GITHUB_ENV + echo "RC_VERSION=${VERSION#*-}" >> $GITHUB_ENV + echo "FULL_VERSION=$VERSION" >> $GITHUB_ENV - git config --global user.name '' - git config --global user.email '' - git add - git commit -m "Bumping Package - $VERSION" \ - -m "" \ - -m "" \ - -m "Co-authored-by: $ACTOR_NAME <$ACTOR_EMAIL>" + - name: Commit changes + id: commit-version-bump + uses: EndBug/add-and-commit@v9.1.1 + with: + author_name: ${{ env.ACTOR_NAME }} + author_email: ${{ env.ACTOR_EMAIL }} + committer_name: "release-ops[bot]" + committer_email: "124938743+release-ops[bot]@users.noreply.github.com" + message: "Bumping Package - ${{ env.FULL_VERSION }}" + push: ${{ env.HAS_PR == 'true' }} # Update existing release branch if available and this is a pre release variant, aka new release candidate - # If version bump is a pre-release just go ahead and publish (dry run or otherwise) - # Do we have any interest in tagging pre-release versions? - - name: Publish pre-release package ${{ inputs.dryRun && '(Dry Run)' || '' }} - if: ${{ startsWith(inputs.versionType, 'pre') }} - env: - NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}} - run: npm publish ${{ inputs.dryRun && '--dry-run' || '' }} - - # If version bump is not a pre-release and not a dry run, create release PR for human review + # If version bump is not a pre-release and not a dry run, create release PR for human review - name: Open Release PR - if: ${{ !inputs.dryRun && !startsWith(inputs.versionType, 'pre') }} + id: create-pr + if: ${{ env.HAS_PR == 'false' && !inputs.dryRun && inputs.versionType != 'prerelease' }} uses: peter-evans/create-pull-request@v4 with: - token: ${{ secrets.BOT_PAT }} + token: ${{ steps.get_auth_token.outputs.token }} delete-branch: true branch: "release/${{ env.VERSION }}" title: "Release: ${{ env.VERSION }}" labels: "release, automated" + author: "${{ env.ACTOR_NAME }} <${{ env.ACTOR_EMAIL }}>" + committer: "release-ops[bot] <124938743+release-ops[bot]@users.noreply.github.com>" + commit-message: "Bumping Package - ${{ env.FULL_VERSION }}" + draft: ${{ startsWith(inputs.versionType, 'pre') }} + + # If a version bump was pushed or a new release pr was created, publish the new variant as long as it's not an official release + - name: Publish pre-release package ${{ inputs.dryRun && '(Dry Run)' || '' }} + if: ${{ startsWith(inputs.versionType, 'pre') && (steps.create-pr.outputs.pull-request-operation == 'created' || steps.commit-version-bump.outputs.pushed == 'true') }} + env: + NODE_AUTH_TOKEN: ${{ secrets.PUBLISH_TOKEN }} + run: npm publish --access public ${{ inputs.dryRun && '--dry-run' || '' }} --tag RC diff --git a/.github/workflows/release-tag.yml b/.github/workflows/release-tag.yml index a70b6b55c..24aced7a7 100644 --- a/.github/workflows/release-tag.yml +++ b/.github/workflows/release-tag.yml @@ -18,9 +18,8 @@ jobs: makeLatest: true generateReleaseNotes: true - publish-sdk-version: + publish-version: name: Publish Version - if: contains(github.ref, 'sdk') runs-on: ubuntu-latest steps: - name: Checkout Source @@ -28,14 +27,15 @@ jobs: - name: Setup Node uses: actions/setup-node@v3 - env: - NODE_AUTH_TOKEN: ${{secrets.BOT_PAT}} with: node-version: 16 - cache: 'npm' + registry-url: 'https://registry.npmjs.org' + scope: ${{ vars.NPM_SCOPE }} # If this is not an organization I have to specify this. - name: Prepare for publish run: npm ci --ignore-scripts - name: Publish package - run: npm publish + env: + NODE_AUTH_TOKEN: ${{ secrets.PUBLISH_TOKEN }} + run: npm publish --access public diff --git a/.github/workflows/tag-release.yml b/.github/workflows/tag-release.yml index 10d67855d..c84288f27 100644 --- a/.github/workflows/tag-release.yml +++ b/.github/workflows/tag-release.yml @@ -35,7 +35,7 @@ jobs: needs: - was_merged - is_release - if: ${{ needs.was_merged.outputs.result == 'true' }} && ${{ needs.is_release.result == 'true' }} + if: ${{ needs.was_merged.outputs.result }} && ${{ needs.is_release.result }} env: PR_BRANCH: ${{ github.event.pull_request.head.ref }} ACTOR_ID: ${{ github.event.pull_request.merged_by.id }} @@ -43,25 +43,32 @@ jobs: MERGE_COMMIT_SHA: ${{ github.event.pull_request.merge_commit_sha }} runs-on: ubuntu-latest steps: + - name: Get Auth Token + uses: tibdex/github-app-token@v1 + id: get_auth_token + with: + app_id: ${{ vars.RELEASE_OPS_APP_ID }} + private_key: ${{ secrets.RELEASE_OPS_PRIVATE_KEY }} + - name: Checkout Source uses: actions/checkout@v3 with: - token: ${{ secrets.BOT_PAT }} + token: ${{ steps.get_auth_token.outputs.token }} - name: Tag commit with version env: + GH_TOKEN: ${{ steps.get_auth_token.outputs.token }} ACTOR: ${{ github.actor }} - GH_TOKEN: ${{secrets.GITHUB_TOKEN}} run: | ACTOR_INFO=$(gh api /users/$ACTOR) ACTOR_ID=$(echo $ACTOR_INFO | jq -r '.id') ACTOR_EMAIL="$ACTOR_ID+$ACTOR@users.noreply.github.com" ACTOR_NAME=$(echo $ACTOR_INFO | jq -r '.name') - TAG_NAME=release-sdk-${PR_BRANCH##*/} - - git config --global user.name '' - git config --global user.email '' + TAG_NAME=release-${PR_BRANCH##*/} + git config --global user.name 'release-ops[bot]' + git config --global user.email 'release-ops[bot]@users.noreply.github.com' + git tag -a $TAG_NAME \ -m "Automated Release $TAG_NAME" \ -m "" \ From bb0c6967682b8c3368ccd7c3af626e046c2a008b Mon Sep 17 00:00:00 2001 From: Jonathon Terry <10217028+Maverick1872@users.noreply.github.com> Date: Thu, 16 Feb 2023 22:45:42 -0700 Subject: [PATCH 12/13] update ci checks to ensure release candidates can't be merged --- .github/workflows/ci.yml | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f6ac3fa29..20abc84a9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,7 +12,28 @@ permissions: contents: read # to fetch code (actions/checkout) jobs: - Tests: + release_checks: + name: Release Checks + runs-on: ubuntu-latest + if: contains( github.event.pull_request.head.ref, 'release') + steps: + - name: Checkout Source + uses: actions/checkout@v3 + + - name: Get version + run: | + echo "RELEASE_VERSION=$(npm pkg get version)" >> $GITHUB_ENV + + - name: Is valid release? + uses: actions/github-script@v6 + with: + script: | + if (process.env.RELEASE_VERSION.includes('RC')) { + core.setFailed('Release candidates are not valid releases!') + } + + tests: + name: Libary Tests permissions: contents: read # to fetch code (actions/checkout) checks: write # to create new checks (coverallsapp/github-action) From 78df9567993fe166deaa4bcae8f915e0c7fa1f77 Mon Sep 17 00:00:00 2001 From: Jonathon Terry <10217028+Maverick1872@users.noreply.github.com> Date: Thu, 16 Feb 2023 22:48:59 -0700 Subject: [PATCH 13/13] revert accidental version bump --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 3a59ba4bd..cd9ec6cf3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "winston", - "version": "3.8.3-0", + "version": "3.8.2", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "winston", - "version": "3.8.3-0", + "version": "3.8.2", "license": "MIT", "dependencies": { "@colors/colors": "1.5.0", diff --git a/package.json b/package.json index d50dbaf8d..979f40bb4 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "winston", "description": "A logger for just about everything.", - "version": "3.8.3-0", + "version": "3.8.2", "author": "Charlie Robbins ", "maintainers": [ "David Hyde "