Skip to content
Open
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
36 changes: 24 additions & 12 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,33 @@ on:

jobs:
release:
# When this workflow is triggered by workflow_dispatch, the optic release
# action will create the release PR targeting the branch that the workflow
# is dispatched from.
#
# We only run this job when it's triggered by workflow_dispatch targeting
# the default branch, unless it's a prerelease, where we allow releases
# against branches other than the default. This is to ensure that actual
# releases tag commits on the main branch, to avoid confusion about where a
# release has come from.
#
# The workflow also runs when either a PR is closed or merged (the `types:
# [closed]` triggers this on both). We skip this job on PRs by authors other
# than optic-release-automation[bot]. When a PR is merged, the bot will
# publish the release to npm. When it's closed, the bot will delete the
# draft release that's created when the PR is opened.
if: >-
${{
(
startsWith(github.event.inputs.semver, 'pre') ||
github.ref == format(
'refs/heads/{0}',
github.event.repository.default_branch
)
) &&
(
github.event_name != 'pull_request' ||
github.event_name == 'workflow_dispatch' &&
(
github.event.pull_request.merged &&
github.event.pull_request.user.login == 'optic-release-automation[bot]'
startsWith(github.event.inputs.semver, 'pre') ||
github.ref == format('refs/heads/{0}', github.event.repository.default_branch)
)
) ||
(
github.event_name == 'pull_request' &&
github.event.pull_request.user.login == 'optic-release-automation[bot]'
)
}}
runs-on: ubuntu-latest
Expand All @@ -51,8 +63,8 @@ jobs:
commit-message: 'Release {version}'
sync-semver-tags: false
access: 'public'
# This prefix is added before the prerelease number, e.g. `v3.0.0-next.0`
prerelease-prefix: 'next'
# This prefix is added before the prerelease number, e.g. `v3.0.0-pre.0`
prerelease-prefix: 'pre'
semver: ${{ github.event.inputs.semver }}
# Prereleases are published under the `next` npm dist-tag
npm-tag: ${{ startsWith(github.event.inputs.semver, 'pre') && 'next' || 'latest' }}
Expand Down