correct cmake file
All checks were successful
Source release / source-package (push) Successful in 31s
All checks were successful
Source release / source-package (push) Successful in 31s
This commit is contained in:
@@ -1,15 +1,18 @@
|
||||
# .gitea/workflows/source-release.yml
|
||||
name: Source release
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- "v*"
|
||||
branches:
|
||||
- master
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
source-package:
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
BUILD_DIR: /tmp/mars-nwe-build
|
||||
|
||||
steps:
|
||||
- name: Check out source
|
||||
@@ -33,32 +36,54 @@ jobs:
|
||||
libcrypt-dev
|
||||
|
||||
- name: Configure
|
||||
run: cmake -S . -B /tmp/mars-nwe-build
|
||||
run: cmake -S . -B "$BUILD_DIR"
|
||||
|
||||
- name: Build source package
|
||||
run: cmake --build /tmp/mars-nwe-build --target package_source
|
||||
run: cmake --build "$BUILD_DIR" --target package_source
|
||||
|
||||
- name: Find source tarball
|
||||
id: pkg
|
||||
run: |
|
||||
FILE="$(find build -maxdepth 2 -type f -name '*.tar.bz2' | head -n1)"
|
||||
FILE="$(find "$BUILD_DIR" -maxdepth 2 -type f -name '*.tar.bz2' | head -n1)"
|
||||
test -n "$FILE"
|
||||
echo "file=$FILE" >> "$GITHUB_OUTPUT"
|
||||
echo "name=$(basename "$FILE")" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Create release if missing
|
||||
- name: Decide release target
|
||||
id: target
|
||||
env:
|
||||
REF_TYPE: ${{ gitea.ref_type || github.ref_type }}
|
||||
REF_NAME: ${{ gitea.ref_name || github.ref_name }}
|
||||
SHA: ${{ gitea.sha || github.sha }}
|
||||
run: |
|
||||
set -e
|
||||
|
||||
if [ "$REF_TYPE" = "tag" ]; then
|
||||
echo "tag=$REF_NAME" >> "$GITHUB_OUTPUT"
|
||||
echo "name=$REF_NAME" >> "$GITHUB_OUTPUT"
|
||||
echo "prerelease=false" >> "$GITHUB_OUTPUT"
|
||||
else
|
||||
SHORT_SHA="$(printf '%s' "$SHA" | cut -c1-7)"
|
||||
echo "tag=development" >> "$GITHUB_OUTPUT"
|
||||
echo "name=development ($REF_NAME @ $SHORT_SHA)" >> "$GITHUB_OUTPUT"
|
||||
echo "prerelease=true" >> "$GITHUB_OUTPUT"
|
||||
fi
|
||||
|
||||
- name: Create or update release
|
||||
env:
|
||||
GITEA_TOKEN: ${{ secrets.RELEASE_TOKEN }}
|
||||
GITEA_API: https://gitea.disconnected-by-peer.at/api/v1
|
||||
OWNER: mars_nwe
|
||||
REPO: mars-nwe
|
||||
TAG: ${{ gitea.ref_name || github.ref_name }}
|
||||
REL_TAG: ${{ steps.target.outputs.tag }}
|
||||
REL_NAME: ${{ steps.target.outputs.name }}
|
||||
REL_PRERELEASE: ${{ steps.target.outputs.prerelease }}
|
||||
run: |
|
||||
set -e
|
||||
|
||||
RELEASE_JSON="$(curl -fsS \
|
||||
-H "Authorization: token ${GITEA_TOKEN}" \
|
||||
"${GITEA_API}/repos/${OWNER}/${REPO}/releases/tags/${TAG}" || true)"
|
||||
"${GITEA_API}/repos/${OWNER}/${REPO}/releases/tags/${REL_TAG}" || true)"
|
||||
|
||||
if [ -z "$RELEASE_JSON" ]; then
|
||||
RELEASE_JSON="$(curl -fsS -X POST \
|
||||
@@ -66,13 +91,47 @@ jobs:
|
||||
-H "Content-Type: application/json" \
|
||||
"${GITEA_API}/repos/${OWNER}/${REPO}/releases" \
|
||||
-d "$(jq -n \
|
||||
--arg tag "$TAG" \
|
||||
--arg name "$TAG" \
|
||||
'{tag_name:$tag,name:$name,draft:false,prerelease:false}')" )"
|
||||
--arg tag "$REL_TAG" \
|
||||
--arg name "$REL_NAME" \
|
||||
--argjson prerelease "$REL_PRERELEASE" \
|
||||
'{tag_name:$tag,name:$name,draft:false,prerelease:$prerelease}')" )"
|
||||
else
|
||||
RELEASE_ID="$(printf '%s' "$RELEASE_JSON" | jq -r '.id')"
|
||||
RELEASE_JSON="$(curl -fsS -X PATCH \
|
||||
-H "Authorization: token ${GITEA_TOKEN}" \
|
||||
-H "Content-Type: application/json" \
|
||||
"${GITEA_API}/repos/${OWNER}/${REPO}/releases/${RELEASE_ID}" \
|
||||
-d "$(jq -n \
|
||||
--arg tag "$REL_TAG" \
|
||||
--arg name "$REL_NAME" \
|
||||
--argjson prerelease "$REL_PRERELEASE" \
|
||||
'{tag_name:$tag,name:$name,draft:false,prerelease:$prerelease}')" )"
|
||||
fi
|
||||
|
||||
echo "$RELEASE_JSON" > release.json
|
||||
jq . release.json
|
||||
|
||||
- name: Delete old asset with same name if present
|
||||
env:
|
||||
GITEA_TOKEN: ${{ secrets.RELEASE_TOKEN }}
|
||||
GITEA_API: https://gitea.disconnected-by-peer.at/api/v1
|
||||
OWNER: mars_nwe
|
||||
REPO: mars-nwe
|
||||
NAME: ${{ steps.pkg.outputs.name }}
|
||||
run: |
|
||||
set -e
|
||||
|
||||
RELEASE_ID="$(jq -r '.id' release.json)"
|
||||
ASSET_ID="$(curl -fsS \
|
||||
-H "Authorization: token ${GITEA_TOKEN}" \
|
||||
"${GITEA_API}/repos/${OWNER}/${REPO}/releases/${RELEASE_ID}" \
|
||||
| jq -r --arg NAME "$NAME" '.assets[]? | select(.name==$NAME) | .id' \
|
||||
| head -n1)"
|
||||
|
||||
if [ -n "$ASSET_ID" ]; then
|
||||
curl -fsS -X DELETE \
|
||||
-H "Authorization: token ${GITEA_TOKEN}" \
|
||||
"${GITEA_API}/repos/${OWNER}/${REPO}/releases/${RELEASE_ID}/assets/${ASSET_ID}"
|
||||
fi
|
||||
|
||||
- name: Upload tarball to release
|
||||
env:
|
||||
@@ -92,3 +151,4 @@ jobs:
|
||||
-H "Content-Type: application/octet-stream" \
|
||||
--data-binary @"${FILE}" \
|
||||
"${GITEA_API}/repos/${OWNER}/${REPO}/releases/${RELEASE_ID}/assets?name=${NAME}"
|
||||
|
||||
Reference in New Issue
Block a user