Skip to content

Commit 5b3c7e5

Browse files
cd: retrieve tag for current SHA and trigger GitHub release with this tag (#174)
* cd: retrieve tag for current SHA and trigger GitHub release with this tag * docs: simplify release workflow description
1 parent f88462d commit 5b3c7e5

File tree

2 files changed

+30
-19
lines changed

2 files changed

+30
-19
lines changed

.github/workflows/release.yml

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,27 @@ jobs:
4646
token: ${{ secrets.CODECOV_TOKEN }}
4747

4848

49-
trigger-github-release:
49+
get-tag-of-current-sha:
5050
needs: build
51+
runs-on: ubuntu-latest
52+
outputs:
53+
tag: ${{ steps.tag-retriever.outputs.tag }}
54+
# Var is empty if command to retrieve tag fails (e.g. if current SHA has no tag associated)
55+
steps:
56+
57+
- uses: actions/checkout@v4
58+
59+
- name: Store tag of SHA if present
60+
id: tag-retriever
61+
run: |
62+
echo "tag=$(git describe --exact-match ${{ github.sha }})" >> "$GITHUB_OUTPUT"
63+
64+
65+
trigger-github-release:
66+
needs: get-tag-of-current-sha
5167
name: Trigger GitHub release workflow
52-
if: github.ref_type == 'tag'
68+
if: needs.get-tag-of-current-sha.outputs.tag
69+
# Runs job only if tag is present.
5370
uses: ./.github/workflows/release-on-github.yml
5471
with:
55-
tag: ${{ github.ref_name }}
72+
tag: ${{ needs.get-tag-of-current-sha.outputs.tag }}

README.md

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -104,22 +104,16 @@ This project uses Maven. To run the tests locally, just run:
104104
mvn clean verify
105105
```
106106

107-
If you are a maintainer, you can release a new version by doing the following:
108-
109-
- Trigger the workflow [prepare-release](./.github/workflows/prepare-release.yml) through the
110-
[web UI](https://github.com/spotify/github-java-client/actions/workflows/prepare-release.yml)
111-
- Select whether the new release should be a `major`, `minor` or `patch` release
112-
- Trigger the release preparation on the `master` branch
113-
- Pushes of this workflow will trigger runs of the workflow
114-
[release](https://github.com/spotify/github-java-client/actions/workflows/release.yml)
115-
- Once the
116-
[release pipeline](https://github.com/spotify/github-java-client/actions/workflows/release.yml)
117-
has completed for the release tag, the new release will be available on Maven Central and the
118-
changes can be released on GitHub
119-
- [Navigate to the tag](https://github.com/spotify/github-java-client/tags) associated with the
120-
changes and generate a manual release
121-
- Once the release is generated, select the "Set as the latest release" checkbox and publish the
122-
release
107+
If you are a maintainer, you can release a new version by just triggering the workflow
108+
[prepare-release](./.github/workflows/prepare-release.yml) through the
109+
[web UI](https://github.com/spotify/github-java-client/actions/workflows/prepare-release.yml).
110+
- Select whether the new release should be a `major`, `minor` or `patch` release
111+
- Trigger the release preparation on the `master` branch
112+
- Pushes of this workflow will trigger runs of the
113+
[maven-release](https://github.com/spotify/github-java-client/actions/workflows/release.yml)
114+
workflow, which in turn will trigger the
115+
[github-release](https://github.com/spotify/github-java-client/actions/workflows/release-on-github.yml)
116+
workflow with the automatically created tag
123117

124118
## Notes about maturity
125119

0 commit comments

Comments
 (0)