diff --git a/.github/workflows/draft-release.yml b/.github/workflows/draft-release.yml new file mode 100644 index 00000000..b8744dbc --- /dev/null +++ b/.github/workflows/draft-release.yml @@ -0,0 +1,93 @@ +name: Draft image release + +permissions: + contents: write + +on: + workflow_dispatch: + inputs: + official_images_pr: + description: Optional official-images PR number to use instead of auto-detect + required: false + type: string + release_tag: + description: Optional explicit release tag, for example v2026.06.1 + required: false + type: string + #schedule: + # - cron: "23 * * * *" + +concurrency: + group: draft-image-release + cancel-in-progress: false + +defaults: + run: + shell: bash -Eeuo pipefail {0} + +jobs: + draft-release: + runs-on: ubuntu-latest + + steps: + - name: Check out repository + uses: actions/checkout@v6 + with: + fetch-depth: 0 + ref: master + + - name: Ensure origin/master is available + run: git fetch origin master + + - name: Generate release draft payload + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + REPO: ${{ github.repository }} + INPUT_OFFICIAL_IMAGES_PR: ${{ inputs.official_images_pr }} + INPUT_RELEASE_TAG: ${{ inputs.release_tag }} + run: .github/scripts/generate-release-draft.sh + + - name: Create or update draft release + if: env.SKIP_RELEASE != 'true' + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + REPO: ${{ github.repository }} + run: | + if gh release view "$RELEASE_TAG" --repo "$REPO" >/dev/null 2>&1; then + echo "Updating existing draft release $RELEASE_TAG" + gh release edit "$RELEASE_TAG" \ + --repo "$REPO" \ + --draft=true \ + --title "$RELEASE_TAG" \ + --notes-file "$RUNNER_TEMP/release-notes.md" + else + echo "Creating draft release $RELEASE_TAG targeting $TARGET_SHA" + gh release create "$RELEASE_TAG" \ + --repo "$REPO" \ + --draft \ + --title "$RELEASE_TAG" \ + --target "$TARGET_SHA" \ + --notes-file "$RUNNER_TEMP/release-notes.md" + fi + + - name: Workflow summary + if: env.SKIP_RELEASE != 'true' + run: | + { + echo "## Draft release prepared" + echo + echo "- Release tag: \`$RELEASE_TAG\`" + echo "- Target SHA: \`$TARGET_SHA\`" + echo "- Previous tag: \`$PREVIOUS_TAG\`" + echo "- Official Images PR: #$OFFICIAL_IMAGES_PR" + echo "- Official Images URL: $OFFICIAL_IMAGES_PR_URL" + } >> "$GITHUB_STEP_SUMMARY" + + - name: Skip summary + if: env.SKIP_RELEASE == 'true' + run: | + { + echo "## No release drafted" + echo + echo "$SKIP_REASON" + } >> "$GITHUB_STEP_SUMMARY"