|
6 | 6 | - main |
7 | 7 | - prerelease/** |
8 | 8 | tags-ignore: |
9 | | - - "*" |
| 9 | + - '*' |
10 | 10 | workflow_dispatch: |
11 | 11 | inputs: |
12 | 12 | prerelease: |
13 | 13 | type: string |
14 | | - 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." |
| 14 | + 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.' |
| 15 | + skip-on-empty: |
| 16 | + type: boolean |
| 17 | + default: true |
| 18 | + description: 'Should release be skipped if there are no semantic commits?' |
| 19 | + generate-readme: |
| 20 | + type: boolean |
| 21 | + default: true |
| 22 | + description: 'Generate oclif readme' |
| 23 | + readme-multi: |
| 24 | + type: boolean |
| 25 | + description: 'Create a different markdown page for each topic.' |
| 26 | + default: false |
15 | 27 |
|
16 | 28 | jobs: |
17 | 29 | release: |
18 | | - uses: salesforcecli/github-workflows/.github/workflows/create-github-release.yml@main |
19 | | - secrets: inherit |
20 | | - with: |
21 | | - prerelease: ${{ inputs.prerelease }} |
22 | | - # If this is a push event, we want to skip the release if there are no semantic commits |
23 | | - # However, if this is a manual release (workflow_dispatch), then we want to disable skip-on-empty |
24 | | - # This helps recover from forgetting to add semantic commits ('fix:', 'feat:', etc.) |
25 | | - skip-on-empty: ${{ github.event_name == 'push' }} |
| 30 | + runs-on: ubuntu-latest |
| 31 | + steps: |
| 32 | + - name: Get Github user info |
| 33 | + id: github-user-info |
| 34 | + uses: salesforcecli/github-workflows/.github/actions/getGithubUserInfo@main |
| 35 | + with: |
| 36 | + SVC_CLI_BOT_GITHUB_TOKEN: ${{ secrets.SVC_CLI_BOT_GITHUB_TOKEN }} |
| 37 | + |
| 38 | + - uses: actions/checkout@v4 |
| 39 | + with: |
| 40 | + token: ${{ secrets.SVC_CLI_BOT_GITHUB_TOKEN }} |
| 41 | + |
| 42 | + - uses: salesforcecli/github-workflows/.github/actions/getPreReleaseTag@main |
| 43 | + id: distTag |
| 44 | + |
| 45 | + - name: Validate prerelease |
| 46 | + if: github.ref_name == 'main' && inputs.prerelease |
| 47 | + uses: actions/github-script@v7 |
| 48 | + with: |
| 49 | + script: | |
| 50 | + core.setFailed('Do not create a prerelease on "main". You can create a prerelease on a branch and when it is merged it will create a non-prerelease Release. For example: 1.0.1-beta.2 will release as 1.0.1 when merged into main.') |
| 51 | +
|
| 52 | + - name: Determine prerelease name |
| 53 | + id: prereleaseTag |
| 54 | + # Only run this step if the ref is not main |
| 55 | + # This will allow us to merge a prerelease PR into main and have it release as a normal release |
| 56 | + if: github.ref_name != 'main' |
| 57 | + run: | |
| 58 | + if [ -n "$INPUTS_PRERELEASE" ]; then |
| 59 | + echo "[INFO] Prerelease input passed in, using: $INPUTS_PRERELEASE" |
| 60 | + echo "tag=$INPUTS_PRERELEASE" >> "$GITHUB_OUTPUT" |
| 61 | + elif [ -n "$STEPS_DISTTAG_TAG" ]; then |
| 62 | + echo "[INFO] Prerelease tag found in package.json, using: $STEPS_DISTTAG_TAG" |
| 63 | + echo "tag=$STEPS_DISTTAG_TAG" >> "$GITHUB_OUTPUT" |
| 64 | + elif [[ "$GITHUB_REF_NAME" =~ ^prerelease/.* ]]; then |
| 65 | + echo "[INFO] Prerelease branch found but no prerelease tag, using default: dev" |
| 66 | + echo "tag=dev" >> "$GITHUB_OUTPUT" |
| 67 | + fi |
| 68 | + env: |
| 69 | + INPUTS_PRERELEASE: ${{ inputs.prerelease }} |
| 70 | + STEPS_DISTTAG_TAG: ${{ steps.distTag.outputs.tag }} |
| 71 | + |
| 72 | + - name: Conventional Changelog Action |
| 73 | + id: changelog |
| 74 | + uses: TriPSs/conventional-changelog-action@3a392e9aa44a72686b0fc13259a90d287dd0877c |
| 75 | + with: |
| 76 | + git-user-name: ${{ steps.github-user-info.outputs.username }} |
| 77 | + git-user-email: ${{ steps.github-user-info.outputs.email }} |
| 78 | + github-token: ${{ secrets.SVC_CLI_BOT_GITHUB_TOKEN }} |
| 79 | + tag-prefix: '' |
| 80 | + # Setting 'release-count' to 0 will keep ALL releases in the change log file (no pruning) |
| 81 | + release-count: '0' |
| 82 | + skip-on-empty: ${{ inputs.skip-on-empty }} |
| 83 | + pre-release: ${{ steps.prereleaseTag.outputs.tag != '' && 'true' || 'false' }} |
| 84 | + pre-release-identifier: ${{ steps.prereleaseTag.outputs.tag }} |
| 85 | + # ternary-ish: https://github.com/actions/runner/issues/409#issuecomment-752775072 |
| 86 | + output-file: ${{ steps.prereleaseTag.outputs.tag != '' && 'false' || 'CHANGELOG.md' }} # If prerelease, do not write the changelog file |
| 87 | + |
| 88 | + - name: Create Github Release |
| 89 | + uses: ncipollo/release-action@2c591bcc8ecdcd2db72b97d6147f871fcd833ba5 |
| 90 | + if: ${{ steps.changelog.outputs.skipped == 'false' }} |
| 91 | + with: |
| 92 | + name: ${{ steps.changelog.outputs.tag }} |
| 93 | + tag: ${{ steps.changelog.outputs.tag }} |
| 94 | + commit: ${{ github.ref_name }} |
| 95 | + body: ${{ steps.changelog.outputs.clean_changelog }} |
| 96 | + prerelease: ${{ steps.prereleaseTag.outputs.tag != '' && 'true' || 'false' }} |
| 97 | + token: ${{ secrets.SVC_CLI_BOT_GITHUB_TOKEN }} |
| 98 | + skipIfReleaseExists: true |
26 | 99 | # docs: |
27 | 100 | # # Most repos won't use this |
28 | 101 | # # Depends on the 'release' job to avoid git collisions, not for any functionality reason |
|
0 commit comments