Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 22 additions & 2 deletions .github/workflows/create-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ on:
workflow_run:
workflows: ['Test PR']
types: [completed]
branches: ['main', 'beta']
branches: ['main', 'beta', 'httpx']

# The release is created with a GitHub App token. This workflow no longer
# commits anything back to the branch (the changelog is rendered in the
Expand All @@ -29,7 +29,7 @@ jobs:

- name: Generate app token
id: app-token
uses: actions/create-github-app-token@v2
uses: actions/create-github-app-token@v3
with:
app-id: ${{ secrets.RELEASE_APP_ID }}
private-key: ${{ secrets.RELEASE_APP_PRIVATE_KEY }}
Expand All @@ -46,7 +46,21 @@ jobs:
echo "prerelease=false" >> "$GITHUB_OUTPUT"
fi

- name: Check if release already exists
id: check-release
env:
GH_TOKEN: ${{ github.token }}
run: |
VERSION="${{ steps.version.outputs.version }}"
if gh release view "$VERSION" > /dev/null 2>&1; then
echo "Release $VERSION already exists, skipping."
echo "exists=true" >> "$GITHUB_OUTPUT"
else
echo "exists=false" >> "$GITHUB_OUTPUT"
fi

- name: Validate version matches branch
if: steps.check-release.outputs.exists == 'false'
run: |
BRANCH="${{ inputs.branch || github.event.workflow_run.head_branch }}"
VERSION="${{ steps.version.outputs.version }}"
Expand All @@ -57,6 +71,11 @@ jobs:
exit 1
fi

if [[ "$BRANCH" == "httpx" && "$PRERELEASE" == "false" ]]; then
echo "::error::httpx branch must have a prerelease version (e.g. 4.0.0b1), got '$VERSION'"
exit 1
fi

if [[ "$BRANCH" == "main" && "$PRERELEASE" == "true" ]]; then
echo "::error::Main branch must not have a prerelease version, got '$VERSION'"
exit 1
Expand All @@ -69,6 +88,7 @@ jobs:
# ruleset, so no git write happens in this workflow. --generate-notes
# below produces the GitHub release body.
- name: Create release
if: steps.check-release.outputs.exists == 'false'
env:
GH_TOKEN: ${{ steps.app-token.outputs.token }}
run: |
Expand Down