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

feat: add release-please action #183

Merged
merged 15 commits into from
Jul 16, 2024
19 changes: 19 additions & 0 deletions .github/workflows/lint-pr-title.yml
Original file line number Diff line number Diff line change
@@ -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 }}
33 changes: 33 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -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 }}
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,23 @@ 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`, we need to make sure that we won't break backwards compatibility.
For this reason we need to provide releasable actions so engineers can review all the incoming changes,
have they set automated update mechanisms (e.g. `dependabot`, `renovate` etc).
zerok marked this conversation as resolved.
Show resolved Hide resolved

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).