mirror of
https://github.com/morgan9e/helium
synced 2026-04-15 00:44:06 +09:00
ci: automatically tag commit and create release
This commit is contained in:
54
.github/workflows/release-and-tag.yml
vendored
Normal file
54
.github/workflows/release-and-tag.yml
vendored
Normal file
@@ -0,0 +1,54 @@
|
||||
name: Create new release on version bump
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
on:
|
||||
push: { branches: ["main"] }
|
||||
|
||||
jobs:
|
||||
check-release:
|
||||
name: Create release if it makes sense
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Clone repository
|
||||
uses: actions/checkout@v4
|
||||
with: { fetch-depth: 0 }
|
||||
|
||||
- name: Check if a new release is needed
|
||||
id: info
|
||||
env:
|
||||
COMMIT_BEFORE: ${{ github.event.before }}
|
||||
COMMIT_AFTER: ${{ github.event.after }}
|
||||
shell: bash
|
||||
run: |
|
||||
mkdir -p dummy && echo 0 > dummy/revision.txt
|
||||
cp utils/helium_version.py .
|
||||
|
||||
git checkout "$COMMIT_BEFORE" \
|
||||
&& OLD_VERSION=$(python3 helium_version.py --tree . --print)
|
||||
|
||||
git checkout "$COMMIT_AFTER" \
|
||||
&& NEW_VERSION=$(python3 helium_version.py --tree . --print)
|
||||
|
||||
if [ "$OLD_VERSION" != "$NEW_VERSION" ]; then
|
||||
echo "version=$NEW_VERSION" >> "$GITHUB_OUTPUT"
|
||||
{
|
||||
printf '### Changelog\n```\n'
|
||||
git log --oneline "$COMMIT_BEFORE..$COMMIT_AFTER"
|
||||
echo '```'
|
||||
} | tee body.md
|
||||
fi
|
||||
|
||||
- name: Create Release
|
||||
if: steps.info.outputs.version
|
||||
id: create_release
|
||||
uses: actions/create-release@latest
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
tag_name: ${{ steps.info.outputs.version }}
|
||||
release_name: ${{ steps.info.outputs.version }}
|
||||
body_path: body.md
|
||||
draft: false
|
||||
prerelease: false
|
||||
24
.github/workflows/release-on-tag.yml
vendored
24
.github/workflows/release-on-tag.yml
vendored
@@ -1,24 +0,0 @@
|
||||
name: Create new empty release
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- '*'
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: Create Release
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Create Release
|
||||
id: create_release
|
||||
uses: actions/create-release@latest
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
tag_name: ${{ github.ref }}
|
||||
release_name: ${{ github.ref }}
|
||||
draft: false
|
||||
prerelease: false
|
||||
Reference in New Issue
Block a user