Make workflows work on GitHub and Gitea
Some checks failed
Dev Verify / verify (push) Failing after 26s
Some checks failed
Dev Verify / verify (push) Failing after 26s
This commit is contained in:
@@ -14,31 +14,21 @@ permissions:
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
container:
|
||||
image: gradle:8.11.1-jdk21
|
||||
env:
|
||||
GITEA_TOKEN: ${{ github.token }}
|
||||
GITEA_API_URL: ${{ github.server_url }}/api/v1
|
||||
GITEA_REPO: ${{ github.repository }}
|
||||
GITEA_REPO_URL: ${{ github.server_url }}/${{ github.repository }}.git
|
||||
GITEA_REF_NAME: ${{ github.ref_name }}
|
||||
GITEA_SHA: ${{ github.sha }}
|
||||
steps:
|
||||
- name: Prepare source
|
||||
shell: bash
|
||||
run: |
|
||||
set -euo pipefail
|
||||
- name: Check out
|
||||
uses: actions/checkout@v4
|
||||
|
||||
if [ ! -f build.gradle ]; then
|
||||
git -c http.extraHeader="Authorization: token ${GITEA_TOKEN}" \
|
||||
clone --depth 1 "${GITEA_REPO_URL}" .
|
||||
fi
|
||||
- name: Set up Java
|
||||
uses: actions/setup-java@v4
|
||||
with:
|
||||
distribution: temurin
|
||||
java-version: 21
|
||||
|
||||
- name: Build
|
||||
shell: bash
|
||||
run: |
|
||||
set -euo pipefail
|
||||
gradle --no-daemon build
|
||||
bash ./gradlew --no-daemon build
|
||||
|
||||
- name: Publish Gitea release
|
||||
if: github.event_name != 'pull_request'
|
||||
@@ -48,12 +38,12 @@ jobs:
|
||||
|
||||
jar_path="$(ls -1 build/libs/*.jar | head -n 1)"
|
||||
if [[ "${GITHUB_REF}" == refs/tags/* ]]; then
|
||||
release_tag="${GITEA_REF_NAME}"
|
||||
release_name="${GITEA_REF_NAME}"
|
||||
release_tag="${GITHUB_REF_NAME}"
|
||||
release_name="${GITHUB_REF_NAME}"
|
||||
prerelease=false
|
||||
else
|
||||
release_tag="build-${GITEA_SHA:0:7}"
|
||||
release_name="build-${GITEA_SHA:0:7}"
|
||||
release_tag="build-${GITHUB_SHA:0:7}"
|
||||
release_name="build-${GITHUB_SHA:0:7}"
|
||||
prerelease=true
|
||||
fi
|
||||
|
||||
@@ -61,10 +51,10 @@ jobs:
|
||||
"${release_tag}" "${release_name}" "${release_name}" "${prerelease}")"
|
||||
|
||||
release_json="$(curl -fsS \
|
||||
-H "Authorization: token ${GITEA_TOKEN}" \
|
||||
-H "Authorization: token ${GITHUB_TOKEN}" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d "${release_payload}" \
|
||||
"${GITEA_API_URL}/repos/${GITEA_REPO}/releases")"
|
||||
"${GITHUB_API_URL}/repos/${GITHUB_REPOSITORY}/releases")"
|
||||
|
||||
release_id="$(printf '%s' "${release_json}" | sed -n 's/.*"id":[[:space:]]*\([0-9][0-9]*\).*/\1/p' | head -n 1)"
|
||||
if [ -z "${release_id}" ]; then
|
||||
@@ -73,8 +63,16 @@ jobs:
|
||||
exit 1
|
||||
fi
|
||||
|
||||
curl -fsS \
|
||||
-H "Authorization: token ${GITEA_TOKEN}" \
|
||||
-H "Content-Type: multipart/form-data" \
|
||||
-F "attachment=@${jar_path}" \
|
||||
"${GITEA_API_URL}/repos/${GITEA_REPO}/releases/${release_id}/assets?name=$(basename "${jar_path}")"
|
||||
if [[ "${GITHUB_SERVER_URL}" == "https://github.com" ]]; then
|
||||
curl -fsS \
|
||||
-H "Authorization: token ${GITHUB_TOKEN}" \
|
||||
-H "Content-Type: application/octet-stream" \
|
||||
--data-binary @"${jar_path}" \
|
||||
"https://uploads.github.com/repos/${GITHUB_REPOSITORY}/releases/${release_id}/assets?name=$(basename "${jar_path}")"
|
||||
else
|
||||
curl -fsS \
|
||||
-H "Authorization: token ${GITHUB_TOKEN}" \
|
||||
-H "Content-Type: multipart/form-data" \
|
||||
-F "attachment=@${jar_path}" \
|
||||
"${GITHUB_API_URL}/repos/${GITHUB_REPOSITORY}/releases/${release_id}/assets?name=$(basename "${jar_path}")"
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user