Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable release workflow with branch protection #57

Merged
merged 14 commits into from
Jul 15, 2024
3 changes: 3 additions & 0 deletions .github/workflows/changelog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ name: Changelog

on:
pull_request:
push:
branches: [ 'push-action/**' ] # enable testing required checks, see https://github.com/CasperWA/push-protected?tab=readme-ov-file#update-your-workflow
workflow_call:
outputs:
release-type:
Expand All @@ -10,6 +12,7 @@ on:

jobs:
validate-changelog:
if: github.base_ref == 'main' || github.base_ref == 'test-main' # check that changelog has valid unreleased changes only in PRs that could trigger a release
runs-on: [ ubuntu-latest ]
outputs:
release-type: ${{ steps.validate-changelog.outputs.release-type }}
Expand Down
23 changes: 15 additions & 8 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
name: Release

on:
push:
branches: [ main ]
pull_request_target:
branches: [ main, test-main ]
types: [ closed ]

jobs:
changelog:
Expand All @@ -12,6 +13,7 @@ jobs:
uses: ./.github/workflows/test.yml

release:
if: github.event.pull_request.merged == true
needs: [ changelog, test ]
runs-on: ubuntu-latest
steps:
Expand All @@ -30,13 +32,18 @@ jobs:
git config user.name "Open Terms Archive Release Bot"
git config user.email "release-bot@opentermsarchive.org"
git commit --message="Update changelog" CHANGELOG.md package.json package-lock.json
git push origin
[ ${{ needs.changelog.outputs.release-type }} != 'no-release' ] && git tag v${{ steps.update-changelog.outputs.version }}

- name: Tag commit
if: needs.changelog.outputs.release-type != 'no-release'
run: |
git tag v${{ steps.update-changelog.outputs.version }}
git push origin --tags
- name: Run status checks for release commit on temporary branch # use temporary branch to enable pushing commits to this branch protected by required status checks
uses: CasperWA/push-protected@v2
with:
token: ${{ secrets.RELEASE_BOT_GITHUB_TOKEN }}
branch: main
acceptable_conclusions: 'success,skipped' # changelog checks are skipped when not in a PR towards main branch
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will become the default value in the next release, see CasperWA/push-protected#250.

tags: true
interval: 10 # seconds between checks
pre_sleep: 15
fail_fast: true

- name: Publish to NPM public repository
if: needs.changelog.outputs.release-type != 'no-release'
Expand Down
6 changes: 2 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@ name: Validate document types

on:
push:
branches-ignore: [ main ] # will be called from workflow call
pull_request:
types: [ opened, reopened ]
branches-ignore: [ main, test-main ] # will be called from workflow call
workflow_call:

jobs:
validate:
runs-on: ubuntu-latest
Expand Down
4 changes: 0 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@ All changes that impact users of this module are documented in this file, in the
- Use [@OpenTermsArchive/changelog-action](https://github.com/OpenTermsArchive/changelog-action/) in CI/CD
- Decrease package size to half

## Unreleased [no-release]
MattiSG marked this conversation as resolved.
Show resolved Hide resolved

_Modifications made in this changeset do not add, remove or alter any behavior, dependency, API or functionality of the software. They only change non-functional parts of the repository, such as the README file or CI workflows._

## 1.1.0 - 2023-10-25

### Added
Expand Down