From 4eb61313448cb0947fb6fdea6dcf3050bbd837d8 Mon Sep 17 00:00:00 2001 From: Willie Ruemmele Date: Mon, 23 Oct 2023 16:00:48 -0600 Subject: [PATCH] chore: add GHAs --- .github/workflows/create-github-release.yml | 28 ++++++++++++++++ .github/workflows/failureNotifications.yml | 2 +- .github/workflows/manualRelease.yml | 36 --------------------- .github/workflows/onPushToMain.yml | 18 ----------- .github/workflows/onRelease.yml | 22 ++++++++++--- 5 files changed, 47 insertions(+), 59 deletions(-) create mode 100644 .github/workflows/create-github-release.yml delete mode 100644 .github/workflows/manualRelease.yml delete mode 100644 .github/workflows/onPushToMain.yml diff --git a/.github/workflows/create-github-release.yml b/.github/workflows/create-github-release.yml new file mode 100644 index 00000000..136463a3 --- /dev/null +++ b/.github/workflows/create-github-release.yml @@ -0,0 +1,28 @@ +name: create-github-release + +on: + push: + branches: + - main + # point at specific branches, or a naming convention via wildcard + - prerelease/** + tags-ignore: + - '*' + workflow_dispatch: + inputs: + prerelease: + type: string + description: 'Name to use for the prerelease: beta, dev, etc. NOTE: If this is already set in the package.json, it does not need to be passed in here.' + +jobs: + release: + # this job will throw if prerelease is true but it doesn't have a prerelease-looking package.json version + uses: salesforcecli/github-workflows/.github/workflows/create-github-release.yml@main + secrets: + SVC_CLI_BOT_GITHUB_TOKEN: ${{ secrets.SVC_CLI_BOT_GITHUB_TOKEN }} + with: + prerelease: ${{ inputs.prerelease }} + # If this is a push event, we want to skip the release if there are no semantic commits + # However, if this is a manual release (workflow_dispatch), then we want to disable skip-on-empty + # This helps recover from forgetting to add semantic commits ('fix:', 'feat:', etc.) + skip-on-empty: ${{ github.event_name == 'push' }} diff --git a/.github/workflows/failureNotifications.yml b/.github/workflows/failureNotifications.yml index 6b4118fc..d3e86d7b 100644 --- a/.github/workflows/failureNotifications.yml +++ b/.github/workflows/failureNotifications.yml @@ -3,7 +3,7 @@ name: failureNotifications on: workflow_run: workflows: - - version, tag and github release + - create-github-release - publish types: - completed diff --git a/.github/workflows/manualRelease.yml b/.github/workflows/manualRelease.yml deleted file mode 100644 index 8ceb52c3..00000000 --- a/.github/workflows/manualRelease.yml +++ /dev/null @@ -1,36 +0,0 @@ -name: manual release - -on: - workflow_dispatch: - -jobs: - release: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - with: - token: ${{ secrets.SVC_CLI_BOT_GITHUB_TOKEN }} - - name: Conventional Changelog Action - id: changelog - uses: TriPSs/conventional-changelog-action@d360fad3a42feca6462f72c97c165d60a02d4bf2 - # overriding some of the basic behaviors to just get the changelog - with: - git-user-name: svc-cli-bot - git-user-email: svc_cli_bot@salesforce.com - github-token: ${{ secrets.SVC_CLI_BOT_GITHUB_TOKEN }} - output-file: false - # always do the release, even if there are no semantic commits - skip-on-empty: false - tag-prefix: '' - - uses: notiz-dev/github-action-json-property@2192e246737701f108a4571462b76c75e7376216 - id: packageVersion - with: - path: 'package.json' - prop_path: 'version' - - name: Create Github Release - uses: actions/create-release@v1 - env: - GITHUB_TOKEN: ${{ secrets.SVC_CLI_BOT_GITHUB_TOKEN }} - with: - tag_name: ${{ steps.packageVersion.outputs.prop }} - release_name: ${{ steps.packageVersion.outputs.prop }} diff --git a/.github/workflows/onPushToMain.yml b/.github/workflows/onPushToMain.yml deleted file mode 100644 index 61eda8ad..00000000 --- a/.github/workflows/onPushToMain.yml +++ /dev/null @@ -1,18 +0,0 @@ -# test -name: version, tag and github release - -on: - push: - branches: [main] - -jobs: - release: - uses: oclif/github-workflows/.github/workflows/githubRelease.yml@main - secrets: inherit - - # most repos won't use this - # depends on previous job to avoid git collisions, not for any functionality reason - # docs: - # uses: salesforcecli/github-workflows/.github/workflows/publishTypedoc.yml@main - # secrets: inherit - # needs: release diff --git a/.github/workflows/onRelease.yml b/.github/workflows/onRelease.yml index 8876db48..02bebdfa 100644 --- a/.github/workflows/onRelease.yml +++ b/.github/workflows/onRelease.yml @@ -2,7 +2,7 @@ name: publish on: release: - types: [released] + types: [published] # support manual release in case something goes wrong and needs to be repeated or tested workflow_dispatch: inputs: @@ -11,9 +11,23 @@ on: type: string required: true jobs: + # parses the package.json version and detects prerelease tag (ex: beta from 4.4.4-beta.0) + getDistTag: + outputs: + tag: ${{ steps.distTag.outputs.tag }} + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + ref: ${{ github.event.release.tag_name || inputs.tag }} + - uses: salesforcecli/github-workflows/.github/actions/getPreReleaseTag@main + id: distTag + npm: - uses: oclif/github-workflows/.github/workflows/npmPublish.yml@main + uses: salesforcecli/github-workflows/.github/workflows/npmPublish.yml@main + needs: [getDistTag] with: - tag: latest + tag: ${{ needs.getDistTag.outputs.tag || 'latest' }} githubTag: ${{ github.event.release.tag_name || inputs.tag }} - secrets: inherit + secrets: + NPM_TOKEN: ${{ secrets.NPM_TOKEN }}