diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 253bcb76b..c21b35cf2 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -2,5 +2,8 @@ version: 2 updates: - package-ecosystem: github-actions directory: / + # Generated by `dist generate` from dist-workspace.toml + exclude-paths: + - .github/workflows/release.yml schedule: interval: daily diff --git a/.github/workflows/create-draft-release.yml b/.github/workflows/create-draft-release.yml deleted file mode 100644 index c8cf4d511..000000000 --- a/.github/workflows/create-draft-release.yml +++ /dev/null @@ -1,40 +0,0 @@ -name: Create draft release - -on: - workflow_call: - inputs: - plan: - required: true - type: string - -jobs: - main: - if: github.event_name != 'pull_request' - runs-on: ubuntu-latest - env: - PLAN: ${{ inputs.plan }} - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - steps: - - name: Plan details - run: | - echo "Plan details: $PLAN" - - - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - - - name: Create draft release - run: | - RELEASE_TAG=$(echo ${PLAN} | jq -r '.announcement_tag') - ANNOUNCEMENT_TITLE=$(echo ${PLAN} | jq -r '.announcement_title') - ANNOUNCEMENT_BODY=$(echo ${PLAN} | jq -r '.announcement_github_body') - - # Write body to file to avoid quoting issues - echo "$ANNOUNCEMENT_BODY" > /tmp/release-notes.txt - - echo "Creating draft release ${RELEASE_TAG}" - # The release will be undrafted by cargo-dist after it has uploaded the artifacts - gh release create "${RELEASE_TAG}" \ - --draft \ - --title "${ANNOUNCEMENT_TITLE}" \ - --notes-file /tmp/release-notes.txt - - echo "Release created successfully" diff --git a/.github/workflows/post-announce.yml b/.github/workflows/post-announce.yml index ace40e966..7c303c961 100644 --- a/.github/workflows/post-announce.yml +++ b/.github/workflows/post-announce.yml @@ -31,10 +31,7 @@ jobs: if [ "${IS_PRE_RELEASE}" == "true" ]; then echo "runner_released=false" >> "$GITHUB_OUTPUT" - echo "Pre-release detected, cargo-dist has already undrafted this release, nothing more to do" - elif [ -z "${NEW_VERSION}" ] || [ "${NEW_VERSION}" == "null" ]; then - echo "runner_released=false" >> "$GITHUB_OUTPUT" - echo "A package other than the runner has been released, cargo-dist has already undrafted this release, nothing more to do" + echo "Pre-release detected, nothing more to do" else echo "runner_released=true" >> "$GITHUB_OUTPUT" echo "Runner version ${NEW_VERSION} was released" @@ -83,15 +80,6 @@ jobs: curl -fsS --retry 3 -o /dev/null \ https://app.codspeed.io/api/ebpf-allowlist - - name: Mark release as latest - if: steps.check_runner.outputs.runner_released == 'true' - run: | - RELEASE_TAG="${{ steps.check_runner.outputs.release_tag }}" - REPO_OWNER=$(echo ${PLAN} | jq -r '.releases[0].hosting.github.owner') - REPO_NAME=$(echo ${PLAN} | jq -r '.releases[0].hosting.github.repo') - echo "Marking release ${RELEASE_TAG} as latest" - gh release edit "${RELEASE_TAG}" -R "${REPO_OWNER}/${REPO_NAME}" --latest - - name: Trigger action runner version bump workflow if: steps.check_runner.outputs.runner_released == 'true' env: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index b10d794c5..661dbe9c4 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -10,8 +10,8 @@ # * uploads those artifacts to temporary workflow zip # * on success, uploads the artifacts to a GitHub Release # -# Note that a GitHub Release with this tag is assumed to exist as a draft -# with the appropriate title/body, and will be undrafted for you. +# Note that the GitHub Release will be created with a generated +# title/body based on your changelogs. name: Release permissions: @@ -165,21 +165,11 @@ jobs: ${{ steps.cargo-dist.outputs.paths }} ${{ env.BUILD_MANIFEST_NAME }} - custom-create-draft-release: - needs: - - plan - if: ${{ needs.plan.outputs.publishing == 'true' || fromJson(needs.plan.outputs.val).ci.github.pr_run_mode == 'upload' }} - uses: $/.github/workflows/create-draft-release.yml - with: - plan: ${{ needs.plan.outputs.val }} - secrets: inherit - # Build and package all the platform-agnostic(ish) things build-global-artifacts: needs: - plan - build-local-artifacts - - custom-create-draft-release runs-on: "ubuntu-22.04" env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -226,10 +216,9 @@ jobs: needs: - plan - build-local-artifacts - - custom-create-draft-release - build-global-artifacts # Only run if we're "publishing", and only if plan, local and global didn't fail (skipped is fine) - if: ${{ always() && needs.plan.result == 'success' && needs.plan.outputs.publishing == 'true' && (needs.build-global-artifacts.result == 'skipped' || needs.build-global-artifacts.result == 'success') && (needs.build-local-artifacts.result == 'skipped' || needs.build-local-artifacts.result == 'success') && (needs.custom-create-draft-release.result == 'skipped' || needs.custom-create-draft-release.result == 'success') }} + if: ${{ always() && needs.plan.result == 'success' && needs.plan.outputs.publishing == 'true' && (needs.build-global-artifacts.result == 'skipped' || needs.build-global-artifacts.result == 'success') && (needs.build-local-artifacts.result == 'skipped' || needs.build-local-artifacts.result == 'success') }} env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} runs-on: "ubuntu-22.04" @@ -280,24 +269,14 @@ jobs: - name: Create GitHub Release env: PRERELEASE_FLAG: "${{ fromJson(steps.host.outputs.manifest).announcement_is_prerelease && '--prerelease' || '' }}" + ANNOUNCEMENT_TITLE: "${{ fromJson(steps.host.outputs.manifest).announcement_title }}" + ANNOUNCEMENT_BODY: "${{ fromJson(steps.host.outputs.manifest).announcement_github_body }}" RELEASE_COMMIT: "${{ github.sha }}" run: | - # If we're editing a release in place, we need to upload things ahead of time - gh release upload "${{ needs.plan.outputs.tag }}" artifacts/* + # Write and read notes from a file to avoid quoting breaking things + echo "$ANNOUNCEMENT_BODY" > $RUNNER_TEMP/notes.txt - # ⚠️ MANUAL EDIT - # Replacement for the generated line - # gh release edit "${{ needs.plan.outputs.tag }}" --target "$RELEASE_COMMIT" $PRERELEASE_FLAG --draft=false - # - # Customize gh release edit call to prevent gh release edit --draft=false from marking the release as latest - # https://github.com/axodotdev/cargo-dist/issues/2244 - export RELEASE_ID=$(gh api repos/{owner}/{repo}/releases --jq '.[] | select(.tag_name == "${{ needs.plan.outputs.tag }}") | .id') - if [ -z "$RELEASE_ID" ]; then - echo "Error: Could not find release ID for tag" - exit 1 - fi - gh api repos/{owner}/{repo}/releases/$RELEASE_ID --method PATCH -f draft=false - # ⚠️ END OF MANUAL EDIT + gh release create "${{ needs.plan.outputs.tag }}" --target "$RELEASE_COMMIT" $PRERELEASE_FLAG --title "$ANNOUNCEMENT_TITLE" --notes-file "$RUNNER_TEMP/notes.txt" artifacts/* announce: needs: diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index c06d39e02..717cf8f75 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -89,12 +89,9 @@ When you run `cargo release --execute `, the following happens: 1. **cargo-release** bumps the version, creates a commit and a git tag, then pushes them to GitHub 2. **GitHub Actions release workflow** triggers on the tag: - - Custom `cargo-dist` job creates a draft GitHub release - - `cargo-dist` builds artifacts for all platforms, uploads them to the draft release, and then publishes it -3. Only if it is a runner release: - - Custom post announce job marks it as "latest" and triggers action repo workflow - -This ensures only stable runner releases are marked as "latest" in GitHub. + - `cargo-dist` builds artifacts for all platforms and creates the GitHub release with them +3. Only if it is a stable release: + - Custom post announce job triggers action repo workflow ## Known issue diff --git a/dist-workspace.toml b/dist-workspace.toml index 140c5e0de..3d544b63d 100644 --- a/dist-workspace.toml +++ b/dist-workspace.toml @@ -23,17 +23,10 @@ install-path = "CARGO_HOME" install-updater = false # Build only the required packages, and individually precise-builds = true -# Don't create GitHub releases, we handle that manually to manually control which release is marked as latest -create-release = false -# Use the stage just after plan because we need its output to create the draft release -local-artifacts-jobs = ["./create-draft-release"] -# Comment this out to rerun `dist generate`, then redo these hand edits to release.yml: -# - the `gh release edit` call in `host` is replaced so the release is not marked as latest -# (https://github.com/axodotdev/cargo-dist/issues/2244) -# - the `swatinem/rust-cache` step in `build-local-artifacts` is removed -allow-dirty = ["ci"] +# `pr-run-mode = "upload"` would otherwise turn on a rust-cache step in every build job +cache-builds = false -# Dependabot bumps the pins in release.yml: copy them here before regenerating +# Pins for the generated release.yml, which dependabot skips: bump them here, then run `dist generate` [dist.github-action-commits] "actions/checkout" = "3d3c42e5aac5ba805825da76410c181273ba90b1" # v7.0.1 "actions/upload-artifact" = "043fb46d1a93c77aae656e7c1c64a875d1fc6a0a" # v7.0.1