diff --git a/.gitea/workflows/release.yml b/.gitea/workflows/release.yml new file mode 100644 index 0000000..4108171 --- /dev/null +++ b/.gitea/workflows/release.yml @@ -0,0 +1,57 @@ +name: release + +on: + push: + branches: + - main + +permissions: + contents: write + +jobs: + release: + runs-on: ubuntu-latest + if: github.event_name == 'push' && startsWith(github.event.head_commit.message, 'Merge pull request') + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Compute next version + id: version + run: | + latest=$(git tag --list 'v[0-9]*' --sort=-v:refname | head -n 1) + if [ -z "$latest" ]; then + next="v1.0.0" + else + latest=${latest#v} + IFS='.' read -r major minor patch <<< "$latest" + next="v${major}.${minor}.$((patch + 1))" + fi + echo "next=${next}" >> "$GITHUB_OUTPUT" + + - name: Build changelog + id: changelog + run: | + prev_tag=$(git describe --tags --abbrev=0 2>/dev/null || echo "") + if [ -z "$prev_tag" ]; then + log=$(git log --oneline --no-merges main | head -n 40) + else + log=$(git log --oneline --no-merges "$prev_tag"..main | head -n 40) + fi + { + echo "body<> "$GITHUB_OUTPUT" + + - name: Create release + uses: softprops/action-gh-release@v2 + with: + tag_name: ${{ steps.version.outputs.next }} + name: ${{ steps.version.outputs.next }} + body: ${{ steps.changelog.outputs.body }} + generate_release_notes: false