Files
prometheus-spigot/.gitea/workflows/build.yml
T
dmg d4a61660c0
Build / build (push) Failing after 6m20s
docs: use built-in gitea token
2026-01-22 22:33:21 -05:00

89 lines
2.7 KiB
YAML

name: Build
on:
push:
branches:
- main
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- 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"