diff --git a/.github/workflows/lint-pr-title.yml b/.github/workflows/lint-pr-title.yml new file mode 100644 index 00000000..c4ff49f2 --- /dev/null +++ b/.github/workflows/lint-pr-title.yml @@ -0,0 +1,19 @@ +name: Lint PR title + +on: + pull_request: + types: [opened, edited, synchronize] + merge_group: + +jobs: + lint-pr-title: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + - id: lint-pr-title + uses: ./actions/lint-pr-title + with: + config-path: "${{ github.workspace }}/actions/lint-pr-title/commitlint.config.js" + env: + GITHUB_TOKEN: ${{ github.token }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..41edb051 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,33 @@ +name: Release shared-workflows + +on: + push: + branches: + - main + +jobs: + release-please: + runs-on: ubuntu-latest + steps: + - uses: googleapis/release-please-action@7987652d64b4581673a76e33ad5e98e3dd56832f # v4.1.3 + id: release + with: + release-type: simple + - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + # this step is needed since we are publishing github actions releases. + # when patching a version e.g. v2.0.0 to v2.0.1, + # we need to make sure that v2 is updated as well as v2.0 + - name: tag major and minor versions + if: ${{ steps.release.outputs.release_created }} + run: | + git config user.name github-actions[bot] + git config user.email github-actions[bot]@users.noreply.github.com + git remote add gh-token "https://${{ github.token }}@github.com/google-github-actions/release-please-action.git" + git tag -d v${{ steps.release.outputs.major }} || true + git tag -d v${{ steps.release.outputs.major }}.${{ steps.release.outputs.minor }} || true + git push origin :v${{ steps.release.outputs.major }} || true + git push origin :v${{ steps.release.outputs.major }}.${{ steps.release.outputs.minor }} || true + git tag -a v${{ steps.release.outputs.major }} -m "Release v${{ steps.release.outputs.major }}" + git tag -a v${{ steps.release.outputs.major }}.${{ steps.release.outputs.minor }} -m "Release v${{ steps.release.outputs.major }}.${{ steps.release.outputs.minor }}" + git push origin v${{ steps.release.outputs.major }} + git push origin v${{ steps.release.outputs.major }}.${{ steps.release.outputs.minor }} diff --git a/README.md b/README.md index 47f13369..4f6e7756 100644 --- a/README.md +++ b/README.md @@ -67,3 +67,21 @@ will ensure actions in this repo are always used at the same commit. To do this: with: some-input: some-value ``` + +### Releasing a version of shared-workflows + +When working with `shared-workflows`, it's essential to avoid breaking backwards compatibility. To ensure this, we must provide releasable actions for engineers to review incoming changes. This also helps automated update tools like `dependabot` and `renovate` to work effectively. + +Upon push to main, a new PR with updates in the CHANGELOG.md will be generated. The author needs to review and approve the PR, then merge. When merged, a new tag with a new release will be shown in the repository's GitHub page. + +In order for the release action to work properly, which means to generate a CHANGELOG for the current release, the pull request titles need to follow the [Conventional Commits specification](https://www.conventionalcommits.org/en/v1.0.0/). This means that the PR should start with a `type` followed by a colon, and then a `subject` - all in lowercase. + +For example: + +- `feat: add new release action` + +Also, the PR description needs to be filled and should never be empty. + +Failing to follow any of the aforementioned necessary steps, will lead to CI failing on your pull request. + +More about how the upstream action works can be found [here](https://github.com/googleapis/release-please-action).