85 lines
2.4 KiB
YAML
85 lines
2.4 KiB
YAML
name: Build & Release
|
|
|
|
on:
|
|
workflow_dispatch:
|
|
|
|
jobs:
|
|
build:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: https://code.forgejo.org/actions/checkout@v4
|
|
|
|
- name: Set up JDK 21
|
|
uses: https://code.forgejo.org/actions/setup-java@v3
|
|
with:
|
|
distribution: 'temurin'
|
|
java-version: '21'
|
|
cache: 'maven'
|
|
|
|
- name: Build with Maven
|
|
run: mvn clean package
|
|
|
|
- name: Upload plugin artifact
|
|
uses: https://code.forgejo.org/actions/upload-artifact@v3
|
|
with:
|
|
name: velocity-plugin
|
|
path: target/*.jar
|
|
|
|
tag:
|
|
needs: build
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: https://code.forgejo.org/actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: Get latest tag
|
|
id: latest_tag
|
|
run: echo "TAG=$(git describe --tags --match 'V1.*' --abbrev=0 || echo 'V1.1.0')" >> $GITHUB_ENV
|
|
|
|
- name: Bump patch version
|
|
id: bump_version
|
|
run: |
|
|
latest_tag="${{ env.TAG }}"
|
|
new_tag=$(echo $latest_tag | awk -F. '{$NF+=1; OFS="."; print $0}')
|
|
echo "NEW_TAG=$new_tag" >> $GITHUB_ENV
|
|
|
|
- name: Generate changelog from commits
|
|
id: changelog
|
|
run: |
|
|
if git rev-parse ${{ env.TAG }} >/dev/null 2>&1; then
|
|
changes=$(git log --pretty=format:"- %s" ${{ env.TAG }}..HEAD)
|
|
else
|
|
changes=$(git log --pretty=format:"- %s")
|
|
fi
|
|
echo "CHANGELOG=$changes" >> $GITHUB_ENV
|
|
|
|
- name: Create new tag
|
|
run: |
|
|
git config --global user.name "forgejo-actions[bot]"
|
|
git config --global user.email "forgejo-actions@users.noreply.forgejo.org"
|
|
git tag -a ${{ env.NEW_TAG }} -m "Automated release ${{ env.NEW_TAG }}"
|
|
git push origin ${{ env.NEW_TAG }}
|
|
|
|
release:
|
|
needs: tag
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: https://code.forgejo.org/actions/checkout@v4
|
|
|
|
- name: Download built JAR
|
|
uses: https://code.forgejo.org/actions/download-artifact@v3
|
|
with:
|
|
name: velocity-plugin
|
|
path: release/
|
|
|
|
- name: Create Forgejo Release
|
|
uses: https://code.forgejo.org/actions/release@v1
|
|
with:
|
|
files: release/*.jar
|
|
tag_name: ${{ env.NEW_TAG }}
|
|
name: "Melon Proxy ${{ env.NEW_TAG }}"
|
|
body: "${{ env.CHANGELOG }}"
|