feat(ci): add gitea release workflow for tag builds
Release / build-and-release (push) Successful in 2m38s
Release / build-and-release (push) Successful in 2m38s
This commit is contained in:
@@ -0,0 +1,77 @@
|
|||||||
|
name: Release
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
tags:
|
||||||
|
- "v*"
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build-and-release:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Check out repository
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Set up JDK 21
|
||||||
|
uses: actions/setup-java@v4
|
||||||
|
with:
|
||||||
|
distribution: temurin
|
||||||
|
java-version: "21"
|
||||||
|
|
||||||
|
- name: Build jar
|
||||||
|
run: ./gradlew build
|
||||||
|
|
||||||
|
- name: Find release artifact
|
||||||
|
id: artifact
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
set -euo pipefail
|
||||||
|
jar=$(find build/libs -maxdepth 1 -type f -name '*.jar' ! -name '*-sources.jar' ! -name '*-javadoc.jar' | head -n 1)
|
||||||
|
if [ -z "${jar}" ]; then
|
||||||
|
echo "No jar artifact found in build/libs" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
echo "path=${jar}" >> "$GITHUB_OUTPUT"
|
||||||
|
echo "name=$(basename "$jar")" >> "$GITHUB_OUTPUT"
|
||||||
|
|
||||||
|
- name: Create Gitea release
|
||||||
|
env:
|
||||||
|
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
if [ -z "${GITEA_TOKEN:-}" ]; then
|
||||||
|
echo "Missing GITEA_TOKEN secret" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
api="${GITHUB_SERVER_URL}/api/v1"
|
||||||
|
repo="${GITHUB_REPOSITORY}"
|
||||||
|
tag="${GITHUB_REF_NAME}"
|
||||||
|
release_name="${tag}"
|
||||||
|
jar_path="${{ steps.artifact.outputs.path }}"
|
||||||
|
jar_name="${{ steps.artifact.outputs.name }}"
|
||||||
|
|
||||||
|
payload=$(jq -n \
|
||||||
|
--arg tag_name "$tag" \
|
||||||
|
--arg name "$release_name" \
|
||||||
|
--arg body "Automated release for $tag" \
|
||||||
|
'{tag_name:$tag_name,name:$name,body:$body,draft:false,prerelease:false}')
|
||||||
|
|
||||||
|
release=$(curl -fsSL \
|
||||||
|
-H "Authorization: token ${GITEA_TOKEN}" \
|
||||||
|
-H "Content-Type: application/json" \
|
||||||
|
-X POST \
|
||||||
|
-d "$payload" \
|
||||||
|
"${api}/repos/${repo}/releases")
|
||||||
|
|
||||||
|
release_id=$(printf '%s' "$release" | jq -r '.id')
|
||||||
|
upload_url="${api}/repos/${repo}/releases/${release_id}/assets?name=${jar_name}"
|
||||||
|
|
||||||
|
curl -fsSL \
|
||||||
|
-H "Authorization: token ${GITEA_TOKEN}" \
|
||||||
|
-H "Content-Type: application/octet-stream" \
|
||||||
|
--data-binary @"${jar_path}" \
|
||||||
|
"${upload_url}"
|
||||||
Reference in New Issue
Block a user