This commit is contained in:
commit
b0ec15d9c4
7 files changed
+393
No files matched your search
@@ -0,0 +1,80 @@
|
||||
name: Build Plugin
|
||||
run-name: Build AsminDiscordBridge
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
- master
|
||||
workflow_dispatch:
|
||||
|
||||
concurrency:
|
||||
group: asmin-discord-bridge-release
|
||||
cancel-in-progress: false
|
||||
|
||||
jobs:
|
||||
build-and-release:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Set up Java 17
|
||||
uses: actions/setup-java@v4
|
||||
with:
|
||||
distribution: temurin
|
||||
java-version: '17'
|
||||
|
||||
- name: Install Gradle 8.7
|
||||
run: |
|
||||
curl -fsSLo /tmp/gradle.zip https://services.gradle.org/distributions/gradle-8.7-bin.zip
|
||||
unzip -q /tmp/gradle.zip -d /tmp
|
||||
echo "/tmp/gradle-8.7/bin" >> "$GITHUB_PATH"
|
||||
|
||||
- name: Calculate next version
|
||||
id: version
|
||||
shell: bash
|
||||
run: |
|
||||
latest="$(git tag --list 'v[0-9]*' --sort=-version:refname | head -n 1)"
|
||||
if [[ -z "$latest" ]]; then
|
||||
version="1.0.0"
|
||||
else
|
||||
current="${latest#v}"
|
||||
IFS='.' read -r major minor patch <<< "$current"
|
||||
if (( patch >= 9 )); then
|
||||
version="$major.$((minor + 1)).0"
|
||||
else
|
||||
version="$major.$minor.$((patch + 1))"
|
||||
fi
|
||||
fi
|
||||
echo "version=$version" >> "$GITHUB_OUTPUT"
|
||||
echo "tag=v$version" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Build plugin
|
||||
run: gradle --no-daemon clean build -PbuildVersion=${{ steps.version.outputs.version }}
|
||||
|
||||
- name: Create Gitea release and upload plugin
|
||||
env:
|
||||
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
|
||||
GITEA_SERVER_URL: ${{ gitea.server_url }}
|
||||
GITEA_REPOSITORY: ${{ gitea.repository }}
|
||||
VERSION: ${{ steps.version.outputs.version }}
|
||||
TAG: ${{ steps.version.outputs.tag }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
if [[ -z "$GITEA_TOKEN" ]]; then
|
||||
echo "Dodaj token z prawem zapisu do repo jako sekret GITEA_TOKEN."
|
||||
exit 1
|
||||
fi
|
||||
jar="AsminDiscordBridge_${VERSION}.jar"
|
||||
api="$GITEA_SERVER_URL/api/v1/repos/$GITEA_REPOSITORY"
|
||||
release="$(curl --fail-with-body -sS -X POST "$api/releases" \
|
||||
-H "Authorization: token $GITEA_TOKEN" \
|
||||
-H 'Content-Type: application/json' \
|
||||
-d "{\"tag_name\":\"$TAG\",\"name\":\"AsminDiscordBridge $VERSION\",\"body\":\"Automatyczny build AsminDiscordBridge $VERSION.\",\"draft\":false,\"prerelease\":false}")"
|
||||
release_id="$(python3 -c 'import json,sys; print(json.load(sys.stdin)["id"])' <<< "$release")"
|
||||
curl --fail-with-body -sS -X POST "$api/releases/$release_id/assets?name=$jar" \
|
||||
-H "Authorization: token $GITEA_TOKEN" \
|
||||
-F "attachment=@build/libs/$jar;filename=$jar"
|
||||
Reference in new issue
Block a user