This commit is contained in:
283
.gitea/workflows/source-release.yml
Normal file
283
.gitea/workflows/source-release.yml
Normal file
@@ -0,0 +1,283 @@
|
||||
name: Source release
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- "v*"
|
||||
branches:
|
||||
- master
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
source-package:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
env:
|
||||
GITEA_API: https://gitea.disconnected-by-peer.at/api/v1
|
||||
OWNER: mars_nwe
|
||||
REPO: ncpfs
|
||||
|
||||
steps:
|
||||
- name: Check out source
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
fetch-tags: true
|
||||
token: ${{ secrets.RELEASE_TOKEN }}
|
||||
|
||||
- name: Fetch tags explicitly
|
||||
run: |
|
||||
git fetch --force --tags
|
||||
echo "describe:"
|
||||
git describe --tags --exact-match || true
|
||||
echo "points-at-head:"
|
||||
git tag --points-at HEAD || true
|
||||
|
||||
- name: Install build dependencies
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y \
|
||||
autoconf \
|
||||
automake \
|
||||
autopoint \
|
||||
gettext \
|
||||
gettext-base \
|
||||
make \
|
||||
gcc \
|
||||
g++ \
|
||||
pkg-config \
|
||||
curl \
|
||||
jq \
|
||||
php-dev \
|
||||
php-cli \
|
||||
libpam0g-dev
|
||||
|
||||
- name: Determine version
|
||||
id: version
|
||||
run: |
|
||||
set -e
|
||||
|
||||
VERSION="$(sed -n 's/^AC_INIT(\[\[ncpfs\]\],\[\[\([^]]*\)\]\].*/\1/p' configure.ac)"
|
||||
|
||||
if [ -z "$VERSION" ]; then
|
||||
echo "Could not determine version from configure.ac"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
|
||||
echo "distfile=ncpfs-${VERSION}.tar.gz" >> "$GITHUB_OUTPUT"
|
||||
|
||||
echo "Version: $VERSION"
|
||||
|
||||
- name: Regenerate configure files
|
||||
run: |
|
||||
set -e
|
||||
|
||||
aclocal
|
||||
autoheader
|
||||
autoconf
|
||||
|
||||
cd contrib/php
|
||||
rm -rf autom4te.cache
|
||||
rm -f configure config.h config.h.in config.log config.status config.cache Makefile Makevars libtool
|
||||
phpize
|
||||
cd ../..
|
||||
|
||||
- name: Configure
|
||||
run: |
|
||||
set -e
|
||||
./configure --with-php-config="$(command -v php-config)"
|
||||
|
||||
- name: Build
|
||||
run: |
|
||||
set -e
|
||||
make
|
||||
|
||||
- name: Clean build artifacts
|
||||
run: |
|
||||
set -e
|
||||
|
||||
make clean || true
|
||||
|
||||
rm -rf \
|
||||
autom4te.cache \
|
||||
.libs \
|
||||
modules
|
||||
|
||||
rm -f \
|
||||
Makefile \
|
||||
Make.rules \
|
||||
config.log \
|
||||
config.status \
|
||||
config.cache \
|
||||
config.nice \
|
||||
libtool \
|
||||
stamp-h1
|
||||
|
||||
rm -rf \
|
||||
contrib/php/autom4te.cache \
|
||||
contrib/php/.deps \
|
||||
contrib/php/.libs \
|
||||
contrib/php/modules \
|
||||
contrib/php/libs
|
||||
|
||||
rm -f \
|
||||
contrib/php/Makefile \
|
||||
contrib/php/Makefile.fragments \
|
||||
contrib/php/Makefile.objects \
|
||||
contrib/php/Makevars \
|
||||
contrib/php/config.h \
|
||||
contrib/php/config.log \
|
||||
contrib/php/config.status \
|
||||
contrib/php/config.cache \
|
||||
contrib/php/config.nice \
|
||||
contrib/php/config_vars.mk \
|
||||
contrib/php/libs.mk \
|
||||
contrib/php/libtool \
|
||||
contrib/php/run-tests.php \
|
||||
contrib/php/*.lo \
|
||||
contrib/php/*.la \
|
||||
contrib/php/*.o \
|
||||
contrib/php/*.dep \
|
||||
contrib/php/*.slo
|
||||
|
||||
find . \
|
||||
\( -name '*.o' \
|
||||
-o -name '*.do' \
|
||||
-o -name '*.to' \
|
||||
-o -name '*.lo' \
|
||||
-o -name '*.la' \
|
||||
-o -name '*.a' \
|
||||
-o -name '*.so' \
|
||||
-o -name '*.so.*' \
|
||||
-o -name '*.dep' \
|
||||
-o -name '*.gcno' \
|
||||
-o -name '*.gcda' \
|
||||
-o -name '*.orig' \
|
||||
-o -name '*.rej' \
|
||||
-o -name '*~' \) \
|
||||
-delete
|
||||
|
||||
find man -name '*.gz' -delete 2>/dev/null || true
|
||||
find ipx-1.0 -name '*.gz' -delete 2>/dev/null || true
|
||||
|
||||
test -f lib/libncp.vers
|
||||
|
||||
- name: Build source tarball
|
||||
id: pkg
|
||||
run: |
|
||||
set -e
|
||||
|
||||
VERSION="${{ steps.version.outputs.version }}"
|
||||
DISTFILE="${{ steps.version.outputs.distfile }}"
|
||||
|
||||
git archive \
|
||||
--format=tar \
|
||||
--prefix="ncpfs-${VERSION}/" \
|
||||
HEAD | gzip -9 > "../${DISTFILE}"
|
||||
|
||||
FILE="$(realpath "../${DISTFILE}")"
|
||||
|
||||
test -s "$FILE"
|
||||
|
||||
echo "file=$FILE" >> "$GITHUB_OUTPUT"
|
||||
echo "name=$DISTFILE" >> "$GITHUB_OUTPUT"
|
||||
|
||||
echo "Created: $FILE"
|
||||
tar -tzf "$FILE" | head -20
|
||||
|
||||
- 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 }}
|
||||
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/${REL_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 "$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
|
||||
|
||||
- name: Delete old asset with same name if present
|
||||
env:
|
||||
GITEA_TOKEN: ${{ secrets.RELEASE_TOKEN }}
|
||||
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:
|
||||
GITEA_TOKEN: ${{ secrets.RELEASE_TOKEN }}
|
||||
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}"
|
||||
|
||||
Reference in New Issue
Block a user