-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add automatic tagging and github release marking
- Loading branch information
1 parent
68ff978
commit 765f6ce
Showing
1 changed file
with
46 additions
and
0 deletions.
There are no files selected for viewing
46 changes: 46 additions & 0 deletions
46
.github/workflows/tag_version_and_mark_as_github_release.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
name: tag_version_and_mark_as_github_release | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
tag_version: | ||
name: tag_version | ||
runs-on: ubuntu-latest | ||
permissions: write-all | ||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
- name: install_hatch | ||
run: pipx install hatch | ||
- name: get_version | ||
run: | | ||
echo "VERSION=$(hatch version)" >> $GITHUB_ENV | ||
- name: check_if_tag_exists_for_version | ||
run: | | ||
if git show-ref --tags --verify --quiet "refs/tags/${VERSION}"; then | ||
echo "Tag ${VERSION} exists." | ||
echo "TAG_EXISTS=true" >> $GITHUB_ENV | ||
else | ||
echo "Tag ${VERSION} does not exist." | ||
echo "TAG_EXISTS=false" >> $GITHUB_ENV | ||
fi | ||
- name: create_release_tag | ||
uses: actions/github-script@v5 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
if: ${{ env.TAG_EXISTS == 'false' }} | ||
with: | ||
script: | | ||
github.rest.git.createRef({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
ref: `refs/tags/${process.env.VERSION}`, | ||
sha: context.sha, | ||
}) |