95 lines
2.7 KiB
YAML
95 lines
2.7 KiB
YAML
# .gitea/workflows/source-release.yml
|
|
name: Source release
|
|
|
|
on:
|
|
push:
|
|
tags:
|
|
- "v*"
|
|
workflow_dispatch:
|
|
|
|
jobs:
|
|
source-package:
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- name: Check out source
|
|
uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0
|
|
submodules: recursive
|
|
|
|
- name: Install build dependencies
|
|
run: |
|
|
apt-get update
|
|
apt-get install -y \
|
|
cmake \
|
|
make \
|
|
gcc \
|
|
g++ \
|
|
pkg-config \
|
|
curl \
|
|
jq \
|
|
libgdbm-dev \
|
|
libcrypt-dev
|
|
|
|
- name: Configure
|
|
run: cmake -S . -B build
|
|
|
|
- name: Build source package
|
|
run: cmake --build build --target package_source
|
|
|
|
- name: Find source tarball
|
|
id: pkg
|
|
run: |
|
|
FILE="$(find build -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
|
|
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 }}
|
|
run: |
|
|
set -e
|
|
|
|
RELEASE_JSON="$(curl -fsS \
|
|
-H "Authorization: token ${GITEA_TOKEN}" \
|
|
"${GITEA_API}/repos/${OWNER}/${REPO}/releases/tags/${TAG}" || true)"
|
|
|
|
if [ -z "$RELEASE_JSON" ]; then
|
|
RELEASE_JSON="$(curl -fsS -X POST \
|
|
-H "Authorization: token ${GITEA_TOKEN}" \
|
|
-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}')" )"
|
|
fi
|
|
|
|
echo "$RELEASE_JSON" > release.json
|
|
jq . release.json
|
|
|
|
- name: Upload tarball to release
|
|
env:
|
|
GITEA_TOKEN: ${{ secrets.RELEASE_TOKEN }}
|
|
GITEA_API: https://gitea.disconnected-by-peer.at/api/v1
|
|
OWNER: mars_nwe
|
|
REPO: mars-nwe
|
|
FILE: ${{ steps.pkg.outputs.file }}
|
|
NAME: ${{ steps.pkg.outputs.name }}
|
|
run: |
|
|
set -e
|
|
|
|
RELEASE_ID="$(jq -r '.id' release.json)"
|
|
|
|
curl -fsS -X POST \
|
|
-H "Authorization: token ${GITEA_TOKEN}" \
|
|
-H "Content-Type: application/octet-stream" \
|
|
--data-binary @"${FILE}" \
|
|
"${GITEA_API}/repos/${OWNER}/${REPO}/releases/${RELEASE_ID}/assets?name=${NAME}"
|