forked from salesforcecli/github-workflows
-
Notifications
You must be signed in to change notification settings - Fork 0
111 lines (102 loc) · 4.75 KB
/
create-github-release.yml
File metadata and controls
111 lines (102 loc) · 4.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
name: create-github-release
on:
workflow_call:
secrets:
SVC_CLI_BOT_GITHUB_TOKEN:
description: A Github PAT with repo write access.
required: true
inputs:
prerelease:
type: string
description: "Name to use for the prerelease: beta, dev, etc."
skip-on-empty:
type: boolean
default: true
description: "Should release be skipped if there are no semantic commits?"
generate-readme:
type: boolean
default: true
description: "Generate oclif readme"
readme-multi:
type: boolean
description: "Create a different markdown page for each topic."
default: false
package-manager:
type: string
description: "Package manager to use (npm or yarn)"
default: "yarn"
required: false
jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Get Github user info
id: github-user-info
uses: llmzy/salesforcecli-github-workflows/.github/actions/getGithubUserInfo@jps/npm-not-yarn
with:
SVC_CLI_BOT_GITHUB_TOKEN: ${{ secrets.SVC_CLI_BOT_GITHUB_TOKEN }}
- uses: actions/checkout@v4
with:
token: ${{ secrets.SVC_CLI_BOT_GITHUB_TOKEN }}
- uses: llmzy/salesforcecli-github-workflows/.github/actions/getPreReleaseTag@jps/npm-not-yarn
id: distTag
- name: Fail if prerelease on main
if: github.ref_name == 'main' && inputs.prerelease
uses: actions/github-script@v7
with:
script: |
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.')
- name: Determine prerelease name
id: prereleaseTag
# Only run this step if the ref is not main
# This will allow us to merge a prerelease PR into main and have it release as a normal release
if: github.ref_name != 'main'
run: |
if [ -n "$INPUTS_PRERELEASE" ]; then
echo "[INFO] Prerelease input passed in, using: $INPUTS_PRERELEASE"
echo "tag=$INPUTS_PRERELEASE" >> "$GITHUB_OUTPUT"
elif [ -n "$STEPS_DISTTAG_TAG" ]; then
echo "[INFO] Prerelease tag found in package.json, using: $STEPS_DISTTAG_TAG"
echo "tag=$STEPS_DISTTAG_TAG" >> "$GITHUB_OUTPUT"
elif [[ "$GITHUB_REF_NAME" =~ ^prerelease/.* ]]; then
echo "[INFO] Prerelease branch found but no prerelease tag, using default: dev"
echo "tag=dev" >> "$GITHUB_OUTPUT"
fi
env:
INPUTS_PRERELEASE: ${{ inputs.prerelease }}
STEPS_DISTTAG_TAG: ${{ steps.distTag.outputs.tag }}
- name: Generate oclif readme
if: ${{ inputs.generate-readme }}
uses: llmzy/salesforcecli-github-workflows/.github/actions/generateOclifReadme@jps/npm-not-yarn
with:
skip-on-empty: ${{ inputs.skip-on-empty }}
pre-release: ${{ steps.prereleaseTag.outputs.tag && 'true' || 'false' }}
pre-release-identifier: ${{ steps.prereleaseTag.outputs.tag }}
multi: ${{ inputs.readme-multi }}
package-manager: ${{ inputs.package-manager }}
- name: Conventional Changelog Action
id: changelog
uses: TriPSs/conventional-changelog-action@3a392e9aa44a72686b0fc13259a90d287dd0877c
with:
git-user-name: ${{ steps.github-user-info.outputs.username }}
git-user-email: ${{ steps.github-user-info.outputs.email }}
github-token: ${{ secrets.SVC_CLI_BOT_GITHUB_TOKEN }}
tag-prefix: ""
# Setting 'release-count' to 0 will keep ALL releases in the change log file (no pruning)
release-count: "0"
skip-on-empty: ${{ inputs.skip-on-empty }}
pre-release: ${{ steps.prereleaseTag.outputs.tag && 'true' || 'false' }}
pre-release-identifier: ${{ steps.prereleaseTag.outputs.tag }}
# ternary-ish: https://github.com/actions/runner/issues/409#issuecomment-752775072
output-file: ${{ steps.prereleaseTag.outputs.tag && 'false' || 'CHANGELOG.md' }} # If prerelease, do not write the changelog file
- name: Create Github Release
uses: ncipollo/release-action@2c591bcc8ecdcd2db72b97d6147f871fcd833ba5
if: ${{ steps.changelog.outputs.skipped == 'false' }}
with:
name: ${{ steps.changelog.outputs.tag }}
tag: ${{ steps.changelog.outputs.tag }}
commit: ${{ github.ref_name }}
body: ${{ steps.changelog.outputs.clean_changelog }}
prerelease: ${{ steps.prereleaseTag.outputs.tag && 'true' || 'false' }}
token: ${{ secrets.SVC_CLI_BOT_GITHUB_TOKEN }}
skipIfReleaseExists: true