Skip to content

Commit

Permalink
feat: add release-please action (#183)
Browse files Browse the repository at this point in the history
* Add lint-pr-title.yml

* Add commitlint.config.js

* Try without explicitly setting the path

* Add release.yml

* Add comments in release.yml

* Update README.md to reflect release changes

* Prettier

* Pin release-please-action version

* Add merge_group to triggers

* Use SHA for checkout step

* Remove skipping pull requests

* Update README.md

* Use self config

* Prettier

* Update README.md
  • Loading branch information
dsotirakis authored Jul 16, 2024
1 parent 0698481 commit 0c6afbf
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 0 deletions.
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 }}
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).

0 comments on commit 0c6afbf

Please sign in to comment.