build: add gitea release workflow

This commit is contained in:
dmg
2026-01-22 22:31:29 -05:00
parent 3e9ce9c3c3
commit 3fc1e31fa8
8 changed files with 136 additions and 1 deletions
+89
View File
@@ -0,0 +1,89 @@
name: Build
on:
push:
branches:
- main
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GITEA_TOKEN }}
- name: Set up Java
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 21
- name: Set up Node
uses: actions/setup-node@v4
with:
node-version: 20
- name: Install Node dependencies
run: npm install
- name: Lint commits
run: |
if [ "${{ github.event.before }}" = "0000000000000000000000000000000000000000" ]; then
FROM=$(git rev-list --max-parents=0 HEAD)
else
FROM="${{ github.event.before }}"
fi
npx commitlint --from "$FROM" --to "${{ github.sha }}"
- name: Release version
env:
GIT_AUTHOR_NAME: "automation"
GIT_AUTHOR_EMAIL: "automation@local"
GIT_COMMITTER_NAME: "automation"
GIT_COMMITTER_EMAIL: "automation@local"
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
run: npx semantic-release
- name: Build
run: ./gradlew build
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: prometheus-spigot-jar
path: build/libs/*.jar
- name: Create release
env:
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
GITEA_API: ${{ vars.GITEA_API_URL }}
run: |
TAG=$(git describe --tags --exact-match 2>/dev/null || true)
if [ -z "$TAG" ]; then
echo "No release tag on HEAD; skipping release."
exit 0
fi
if [ -z "$GITEA_API" ]; then
echo "GITEA_API_URL is not set in repo variables."
exit 1
fi
VERSION=${TAG#v}
JAR_PATH=$(ls build/libs/*.jar | head -n 1)
RELEASE_ID=$(curl -sS -X POST \
-H "Authorization: token ${GITEA_TOKEN}" \
-H "Content-Type: application/json" \
"${GITEA_API}/repos/${GITHUB_REPOSITORY}/releases" \
-d "{\"tag_name\":\"${TAG}\",\"name\":\"${TAG}\",\"draft\":false,\"prerelease\":false}" \
| python -c "import sys, json; print(json.load(sys.stdin).get('id', ''))")
if [ -z "$RELEASE_ID" ]; then
echo "Failed to create release."
exit 1
fi
curl -sS -X POST \
-H "Authorization: token ${GITEA_TOKEN}" \
-H "Content-Type: application/octet-stream" \
--data-binary "@${JAR_PATH}" \
"${GITEA_API}/repos/${GITHUB_REPOSITORY}/releases/${RELEASE_ID}/assets?name=prometheus-spigot-${VERSION}.jar"
+1
View File
@@ -4,5 +4,6 @@
.settings/ .settings/
build/ build/
out/ out/
node_modules/
*.iml *.iml
.DS_Store .DS_Store
+23
View File
@@ -0,0 +1,23 @@
module.exports = {
branches: ["main"],
tagFormat: "v${version}",
plugins: [
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
[
"@semantic-release/exec",
{
prepareCmd:
"node -e \"const fs=require('fs');fs.writeFileSync('gradle.properties', 'version=' + process.env.RELEASE_VERSION + '\\n');\"",
},
],
[
"@semantic-release/git",
{
assets: ["gradle.properties"],
message:
"chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}",
},
],
],
};
+7
View File
@@ -67,6 +67,13 @@ scrape_configs:
credentials: "<bearer_token>" credentials: "<bearer_token>"
``` ```
## CI Release Notes
The Gitea workflow expects these secrets/variables:
- `GITEA_TOKEN`: token with repo write access for tags/releases.
- `GITEA_API_URL`: API base URL, for example `https://git.garvis.dev/api/v1`.
## Metrics ## Metrics
Some metrics depend on server implementations (TPS/MSPT, player ping, tile entities). If a method is unavailable on your server build, those metrics are omitted. Some metrics depend on server implementations (TPS/MSPT, player ping, tile entities). If a method is unavailable on your server build, those metrics are omitted.
+1 -1
View File
@@ -3,7 +3,7 @@ plugins {
} }
group = "com.prometheus" group = "com.prometheus"
version = "0.1.0" version = project.findProperty("version")?.toString() ?: "0.1.0"
repositories { repositories {
mavenCentral() mavenCentral()
+3
View File
@@ -0,0 +1,3 @@
module.exports = {
extends: ["@commitlint/config-conventional"],
};
+1
View File
@@ -0,0 +1 @@
version=0.1.0
+11
View File
@@ -0,0 +1,11 @@
{
"name": "prometheus-spigot",
"private": true,
"devDependencies": {
"@commitlint/cli": "^19.5.0",
"@commitlint/config-conventional": "^19.5.0",
"@semantic-release/exec": "^6.0.3",
"@semantic-release/git": "^10.0.1",
"semantic-release": "^23.1.1"
}
}