@@ -39,31 +39,27 @@ permissions:
3939# If there's a prerelease-style suffix to the version, then the release(s)
4040# will be marked as a prerelease.
4141on :
42- workflow_dispatch :
43-
44- workflow_call :
45- inputs :
46- tag :
47- description : ' Tag to publish'
48- required : true
49- type : string
42+ pull_request :
43+ push :
44+ tags :
45+ - ' **[0-9]+.[0-9]+.[0-9]+*'
5046
5147jobs :
5248 # Run 'dist plan' (or host) to determine what tasks we need to do
5349 plan :
5450 runs-on : " ubuntu-22.04"
5551 outputs :
5652 val : ${{ steps.plan.outputs.manifest }}
57- tag : ${{ inputs.tag }}
58- tag-flag : ${{ format('--tag={0}', inputs.tag) }}
59- publishing : true
53+ tag : ${{ !github.event.pull_request && github.ref_name || '' }}
54+ tag-flag : ${{ !github.event.pull_request && format('--tag={0}', github.ref_name) || '' }}
55+ publishing : ${{ !github.event.pull_request }}
6056 env :
6157 GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
6258 steps :
6359 - uses : actions/checkout@v6
6460 with :
6561 persist-credentials : false
66- ref : ${{ inputs.tag }}
62+ submodules : recursive
6763 - name : Install dist
6864 # we specify bash to get pipefail; it guards against the `curl` command
6965 # failing. otherwise `sh` won't catch that `curl` returned non-0
8177 # but also really annoying to build CI around when it needs secrets to work right.)
8278 - id : plan
8379 run : |
84- dist ${{ format('host --steps=create --tag={0}', inputs.tag ) || 'plan' }} --output-format=json > plan-dist-manifest.json
80+ dist ${{ (!github.event.pull_request && format('host --steps=create --tag={0}', github.ref_name) ) || 'plan' }} --output-format=json > plan-dist-manifest.json
8581 echo "dist ran successfully"
8682 cat plan-dist-manifest.json
8783 echo "manifest=$(jq -c "." plan-dist-manifest.json)" >> "$GITHUB_OUTPUT"
@@ -282,14 +278,30 @@ jobs:
282278
283279 gh release create "${{ needs.plan.outputs.tag }}" --target "$RELEASE_COMMIT" $PRERELEASE_FLAG --title "$ANNOUNCEMENT_TITLE" --notes-file "$RUNNER_TEMP/notes.txt" artifacts/*
284280
281+ custom-publish_to_cargo :
282+ needs :
283+ - plan
284+ - host
285+ if : ${{ !fromJson(needs.plan.outputs.val).announcement_is_prerelease || fromJson(needs.plan.outputs.val).publish_prereleases }}
286+ uses : ./.github/workflows/publish_to_cargo.yml
287+ with :
288+ plan : ${{ needs.plan.outputs.val }}
289+ tag : ${{ needs.plan.outputs.tag }}
290+ secrets : inherit
291+ # publish jobs get escalated permissions
292+ permissions :
293+ " id-token " : " write"
294+ " packages " : " write"
295+
285296 announce :
286297 needs :
287298 - plan
288299 - host
300+ - custom-publish_to_cargo
289301 # use "always() && ..." to allow us to wait for all publish jobs while
290302 # still allowing individual publish jobs to skip themselves (for prereleases).
291303 # "host" however must run to completion, no skipping allowed!
292- if : ${{ always() && needs.host.result == 'success' }}
304+ if : ${{ always() && needs.host.result == 'success' && (needs.custom-publish_to_cargo.result == 'skipped' || needs.custom-publish_to_cargo.result == 'success') }}
293305 runs-on : " ubuntu-22.04"
294306 env :
295307 GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
0 commit comments