Merge pull request #3 from Salastil/codex/add-build-scripts-for-versioned-tags
Build releases on tagged pushes
This commit is contained in:
32
.github/workflows/release.yml
vendored
32
.github/workflows/release.yml
vendored
@@ -3,6 +3,9 @@ name: Build release binaries
|
|||||||
on:
|
on:
|
||||||
release:
|
release:
|
||||||
types: [published]
|
types: [published]
|
||||||
|
push:
|
||||||
|
tags:
|
||||||
|
- "v*"
|
||||||
|
|
||||||
permissions:
|
permissions:
|
||||||
contents: write
|
contents: write
|
||||||
@@ -95,6 +98,7 @@ jobs:
|
|||||||
if: startsWith(github.server_url, 'https://github.com')
|
if: startsWith(github.server_url, 'https://github.com')
|
||||||
uses: softprops/action-gh-release@v2
|
uses: softprops/action-gh-release@v2
|
||||||
with:
|
with:
|
||||||
|
tag_name: ${{ github.ref_name }}
|
||||||
files: dist/*
|
files: dist/*
|
||||||
|
|
||||||
- name: Publish release assets on Gitea
|
- name: Publish release assets on Gitea
|
||||||
@@ -102,11 +106,37 @@ jobs:
|
|||||||
env:
|
env:
|
||||||
API_URL: ${{ github.api_url }}
|
API_URL: ${{ github.api_url }}
|
||||||
REPOSITORY: ${{ github.repository }}
|
REPOSITORY: ${{ github.repository }}
|
||||||
RELEASE_ID: ${{ github.event.release.id }}
|
|
||||||
TOKEN: ${{ secrets.CI_TOKEN || secrets.GITHUB_TOKEN || github.token }}
|
TOKEN: ${{ secrets.CI_TOKEN || secrets.GITHUB_TOKEN || github.token }}
|
||||||
|
RELEASE_ID: ${{ github.event.release.id }}
|
||||||
|
TAG_NAME: ${{ github.ref_name }}
|
||||||
run: |
|
run: |
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
shopt -s nullglob
|
shopt -s nullglob
|
||||||
|
|
||||||
|
if [ -z "${RELEASE_ID:-}" ]; then
|
||||||
|
echo "Creating release ${TAG_NAME} on Gitea"
|
||||||
|
response=$(curl -sfSL -X POST \
|
||||||
|
-H "Authorization: token ${TOKEN}" \
|
||||||
|
-H "Content-Type: application/json" \
|
||||||
|
-d "{\"tag_name\":\"${TAG_NAME}\",\"name\":\"${TAG_NAME}\",\"draft\":false,\"prerelease\":false}" \
|
||||||
|
"${API_URL}/repos/${REPOSITORY}/releases")
|
||||||
|
|
||||||
|
RELEASE_ID=$(python - "$response" <<'PY'
|
||||||
|
import json, sys
|
||||||
|
try:
|
||||||
|
data = json.loads(sys.argv[1])
|
||||||
|
print(data.get("id", ""))
|
||||||
|
except Exception:
|
||||||
|
sys.exit(1)
|
||||||
|
PY
|
||||||
|
)
|
||||||
|
|
||||||
|
if [ -z "${RELEASE_ID}" ]; then
|
||||||
|
echo "Failed to create release" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
for file in dist/*; do
|
for file in dist/*; do
|
||||||
name=$(basename "${file}")
|
name=$(basename "${file}")
|
||||||
curl -sfSL -X POST \
|
curl -sfSL -X POST \
|
||||||
|
|||||||
Reference in New Issue
Block a user