diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index c816275230f6cf..2cbfcd20943b7f 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -16,7 +16,7 @@ name: Release permissions: contents: write -# This task will run whenever you push a git tag that looks like a version +# This task will run whenever you workflow_dispatch with a tag that looks like a version # like "1.0.0", "v0.1.0-prerelease.1", "my-app/0.1.0", "releases/v1.0.0", etc. # Various formats will be parsed into a VERSION and an optional PACKAGE_NAME, where # PACKAGE_NAME must be the name of a Cargo package in your workspace, and VERSION @@ -39,9 +39,13 @@ permissions: # will be marked as a prerelease. on: pull_request: - push: - tags: - - '**[0-9]+.[0-9]+.[0-9]+*' + workflow_dispatch: + inputs: + tag: + description: Release Tag + required: true + default: dry-run + type: string jobs: # Run 'cargo dist plan' (or host) to determine what tasks we need to do @@ -49,9 +53,9 @@ jobs: runs-on: "ubuntu-20.04" outputs: val: ${{ steps.plan.outputs.manifest }} - tag: ${{ !github.event.pull_request && github.ref_name || '' }} - tag-flag: ${{ !github.event.pull_request && format('--tag={0}', github.ref_name) || '' }} - publishing: ${{ !github.event.pull_request }} + tag: ${{ (inputs.tag != 'dry-run' && inputs.tag) || '' }} + tag-flag: ${{ inputs.tag && inputs.tag != 'dry-run' && format('--tag={0}', inputs.tag) || '' }} + publishing: ${{ inputs.tag && inputs.tag != 'dry-run' }} env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} steps: @@ -70,7 +74,7 @@ jobs: # but also really annoying to build CI around when it needs secrets to work right.) - id: plan run: | - cargo dist ${{ (!github.event.pull_request && format('host --steps=create --tag={0}', github.ref_name)) || 'plan' }} --output-format=json > plan-dist-manifest.json + cargo dist ${{ (inputs.tag && inputs.tag != 'dry-run' && format('host --steps=create --tag={0}', inputs.tag)) || 'plan' }} --output-format=json > plan-dist-manifest.json echo "cargo dist ran successfully" cat plan-dist-manifest.json echo "manifest=$(jq -c "." plan-dist-manifest.json)" >> "$GITHUB_OUTPUT" @@ -86,7 +90,7 @@ jobs: # Let the initial task tell us to not run (currently very blunt) needs: - plan - if: ${{ fromJson(needs.plan.outputs.val).ci.github.artifacts_matrix.include != null && (needs.plan.outputs.publishing == 'true' || fromJson(needs.plan.outputs.val).ci.github.pr_run_mode == 'upload') }} + if: ${{ fromJson(needs.plan.outputs.val).ci.github.artifacts_matrix.include != null && (needs.plan.outputs.publishing == 'true' || fromJson(needs.plan.outputs.val).ci.github.pr_run_mode == 'upload') || inputs.tag == 'dry-run' }} strategy: fail-fast: false # Target platforms/runners are computed by cargo-dist in create-release. diff --git a/Cargo.toml b/Cargo.toml index d57b588e27e420..43d6f8e4073fd6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -97,7 +97,8 @@ windows-archive = ".tar.gz" unix-archive = ".tar.gz" # Publish jobs to run in CI pr-run-mode = "plan" -dispatch-release = true +# Whether CI should trigger releases with dispatches instead of tag pushes +dispatch-releases = true [workspace.metadata.dist.dependencies.homebrew] protobuf = "*"