11name : Nais CLI
22on :
33 pull_request :
4- types : [opened, reopened, synchronize]
4+ types : [opened, reopened, synchronize, labeled ]
55 push :
66 branches : [main]
77 paths-ignore : ["**.md"]
@@ -10,6 +10,8 @@ concurrency:
1010 cancel-in-progress : true
1111permissions :
1212 contents : read
13+ env :
14+ PRE_RELEASE : ${{ github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'pre-release') && 'true' || 'false' }}
1315jobs :
1416 release-info :
1517 runs-on : ubuntu-latest
1921 outputs :
2022 version : ${{ steps.release-info.outputs.version }}
2123 changelog : ${{ steps.release-info.outputs.changelog }}
24+ pre_release : ${{ steps.release-info.outputs.pre_release }}
2225 steps :
2326 - uses : actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # ratchet:actions/checkout@v6
2427 with :
2932 env :
3033 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
3134 IS_FORK : ${{ github.event.pull_request.head.repo.full_name != github.repository }}
35+ PRE_RELEASE : ${{ env.PRE_RELEASE }}
36+ PR_NUMBER : ${{ github.event.pull_request.number }}
3237 checks :
3338 strategy :
3439 matrix :
@@ -97,7 +102,13 @@ jobs:
97102 release-github :
98103 permissions :
99104 contents : write
100- if : github.ref == 'refs/heads/main' && needs.release-info.outputs.changelog != '' && needs.release-info.outputs.version != ''
105+ if : >-
106+ needs.release-info.outputs.changelog != '' &&
107+ needs.release-info.outputs.version != '' &&
108+ (
109+ (github.ref == 'refs/heads/main' && github.actor != 'dependabot[bot]') ||
110+ needs.release-info.outputs.pre_release == 'true'
111+ )
101112 runs-on : ubuntu-latest
102113 needs : [release-info, branch-protection-checkpoint]
103114 steps :
@@ -115,17 +126,20 @@ jobs:
115126 id : release
116127 with :
117128 tag_name : v${{ needs.release-info.outputs.version }}
129+ target_commitish : ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
118130 body : ${{ needs.release-info.outputs.changelog }}
119- prerelease : false
131+ prerelease : ${{ env.PRE_RELEASE == 'true' }}
120132 files : ./release_artifacts/*
121133 env :
122134 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
123- - env :
135+ - if : env.PRE_RELEASE != 'true'
136+ env :
124137 VERSION : ${{ needs.release-info.outputs.version }}
125138 run : |
126139 echo '${{ steps.release.outputs.assets }}' > assets.json
127140 mise run ci:prepare-template-vars ./release_artifacts/checksums.txt ./assets.json -v > template.vars
128- - uses : actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # ratchet:actions/upload-artifact@v5
141+ - if : env.PRE_RELEASE != 'true'
142+ uses : actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # ratchet:actions/upload-artifact@v5
129143 with :
130144 name : template-vars
131145 path : ./template.vars
@@ -134,8 +148,8 @@ jobs:
134148 echo "## :rocket: Release v${{ needs.release-info.outputs.version }}" >> $GITHUB_STEP_SUMMARY
135149 echo "A new release is available over at https://github.com/${{ github.repository }}/releases/tag/v${{ needs.release-info.outputs.version }}." >> $GITHUB_STEP_SUMMARY
136150 release-gar :
137- if : github.ref == 'refs/heads/main'
138- needs : [release-github]
151+ if : github.ref == 'refs/heads/main' && needs.release-info.outputs.pre_release != 'true'
152+ needs : [release-info, release- github]
139153 runs-on : ubuntu-latest
140154 permissions :
141155 contents : read
@@ -160,8 +174,8 @@ jobs:
160174 gcloud --project nais-io artifacts apt upload nais-ppa --quiet --source nais-cli_arm64.deb --location europe-north1
161175 gcloud --project nais-io artifacts apt upload nais-ppa --quiet --source nais-cli_amd64.deb --location europe-north1
162176 release-external-repos :
163- if : github.ref == 'refs/heads/main'
164- needs : [release-github]
177+ if : github.ref == 'refs/heads/main' && needs.release-info.outputs.pre_release != 'true'
178+ needs : [release-info, release- github]
165179 runs-on : ubuntu-latest
166180 strategy :
167181 fail-fast : false
0 commit comments