diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index c6ace06..7ab9080 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -3,7 +3,9 @@ name: Release on: workflow_dispatch: - push: + pull_request: + types: + - closed branches: - main @@ -12,6 +14,16 @@ permissions: jobs: create_release: + # release if + # manual deployment OR + # merged to main and labelled with release labels + if: | + (github.event_name == 'workflow_dispatch') || + (github.event.pull_request.merged == true && + (contains(github.event.pull_request.labels.*.name, 'breaking') || + contains(github.event.pull_request.labels.*.name, 'enhancement') || + contains(github.event.pull_request.labels.*.name, 'vuln') || + contains(github.event.pull_request.labels.*.name, 'release'))) outputs: full-tag: ${{ steps.release-drafter.outputs.tag_name }} short-tag: ${{ steps.get_tag_name.outputs.SHORT_TAG }} @@ -34,6 +46,7 @@ jobs: short_tag=$(echo ${{ steps.release-drafter.outputs.tag_name }} | cut -d. -f1) echo "SHORT_TAG=$short_tag" >> $GITHUB_OUTPUT create_action_images: + if: github.event.pull_request.merged == true needs: create_release runs-on: ubuntu-latest permissions: @@ -66,6 +79,7 @@ jobs: provenance: false sbom: false create_discussion: + if: github.event.pull_request.merged == true needs: create_release runs-on: ubuntu-latest permissions: diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index bed38d4..f6f601d 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -78,4 +78,6 @@ We are using [Conventional Commits](https://www.conventionalcommits.org/en/v1.0. ## Releases -Releases are automated but if you need to manually initiate a release you can do so through the GitHub Actions UI. If you have permissions to do so, you can navigate to the [Actions tab](https://github.com/github/stale-repos/actions/workflows/release.yml) and select the `Run workflow` button. This will allow you to select the branch to release from and the version to release. +Releases are automated if a pull request is labelled with our [semver related labels](.github/release-drafter.yml) or with the `vuln` or `release` labels. + +You can also manually initiate a release you can do so through the GitHub Actions UI. If you have permissions to do so, you can navigate to the [Actions tab](https://github.com/github/stale-repos/actions/workflows/release.yml) and select the `Run workflow` button. This will allow you to select the branch to release from and the version to release.