action release
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
# .gitea/workflows/source-release.yml
|
||||
name: Source release
|
||||
|
||||
on:
|
||||
@@ -26,6 +27,8 @@ jobs:
|
||||
gcc \
|
||||
g++ \
|
||||
pkg-config \
|
||||
curl \
|
||||
jq \
|
||||
libgdbm-dev \
|
||||
libcrypt-dev
|
||||
|
||||
@@ -35,15 +38,57 @@ jobs:
|
||||
- name: Build source package
|
||||
run: cmake --build build --target package_source
|
||||
|
||||
- name: List generated files
|
||||
- name: Find source tarball
|
||||
id: pkg
|
||||
run: |
|
||||
find build -maxdepth 2 \( -name '*.tar.bz2' -o -name '*.tbz2' \) -print
|
||||
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: Upload workflow artifact
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: mars-nwe-source-package
|
||||
path: |
|
||||
build/*.tar.bz2
|
||||
build/*.tbz2
|
||||
if-no-files-found: error
|
||||
- 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}"
|
||||
|
||||
Reference in New Issue
Block a user