Publish release builds to Gitea packages
All checks were successful
Build / Test and build (push) Successful in 5m37s
All checks were successful
Build / Test and build (push) Successful in 5m37s
This commit is contained in:
@@ -8,9 +8,15 @@ on:
|
|||||||
- "v*"
|
- "v*"
|
||||||
pull_request:
|
pull_request:
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
inputs:
|
||||||
|
publish_version:
|
||||||
|
description: Version to publish to the Gitea package registry
|
||||||
|
required: false
|
||||||
|
type: string
|
||||||
|
|
||||||
permissions:
|
permissions:
|
||||||
contents: read
|
contents: read
|
||||||
|
packages: write
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
@@ -38,14 +44,23 @@ jobs:
|
|||||||
BUILD_REF: ${{ github.ref }}
|
BUILD_REF: ${{ github.ref }}
|
||||||
BUILD_REF_NAME: ${{ github.ref_name }}
|
BUILD_REF_NAME: ${{ github.ref_name }}
|
||||||
BUILD_SHA: ${{ github.sha }}
|
BUILD_SHA: ${{ github.sha }}
|
||||||
|
PUBLISH_VERSION: ${{ inputs.publish_version }}
|
||||||
run: |
|
run: |
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
package_version="snapshot-${BUILD_SHA:0:8}"
|
package_version="snapshot-${BUILD_SHA:0:8}"
|
||||||
version_flags=""
|
version_flags=""
|
||||||
if [[ "$BUILD_REF" == refs/tags/v* ]]; then
|
if [[ "$BUILD_REF" == refs/tags/v* ]]; then
|
||||||
package_version="${BUILD_REF_NAME//\//-}"
|
package_version="$BUILD_REF_NAME"
|
||||||
version_flags="-X main.version=$BUILD_REF_NAME"
|
elif [[ -n "$PUBLISH_VERSION" ]]; then
|
||||||
|
package_version="$PUBLISH_VERSION"
|
||||||
|
fi
|
||||||
|
if [[ "$package_version" != snapshot-* ]]; then
|
||||||
|
if [[ ! "$package_version" =~ ^v[0-9]+\.[0-9]+\.[0-9]+([.-][0-9A-Za-z.-]+)?$ ]]; then
|
||||||
|
echo "Invalid release version: $package_version" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
version_flags="-X main.version=$package_version"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
mkdir -p dist
|
mkdir -p dist
|
||||||
@@ -84,3 +99,33 @@ jobs:
|
|||||||
dist/SHA256SUMS
|
dist/SHA256SUMS
|
||||||
if-no-files-found: error
|
if-no-files-found: error
|
||||||
retention-days: 30
|
retention-days: 30
|
||||||
|
|
||||||
|
- name: Publish Gitea package
|
||||||
|
if: startsWith(github.ref, 'refs/tags/v') || inputs.publish_version != ''
|
||||||
|
shell: bash
|
||||||
|
env:
|
||||||
|
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
|
||||||
|
GITEA_SERVER_URL: ${{ github.server_url }}
|
||||||
|
GITEA_OWNER: ${{ github.repository_owner }}
|
||||||
|
GITEA_REPOSITORY: ${{ github.repository }}
|
||||||
|
BUILD_REF_NAME: ${{ github.ref_name }}
|
||||||
|
PUBLISH_VERSION: ${{ inputs.publish_version }}
|
||||||
|
run: |
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
package_version="${PUBLISH_VERSION:-$BUILD_REF_NAME}"
|
||||||
|
repository_name="${GITEA_REPOSITORY#*/}"
|
||||||
|
package_url="$GITEA_SERVER_URL/api/packages/$GITEA_OWNER/generic/bdrclone/$package_version"
|
||||||
|
|
||||||
|
for package_file in dist/*.tar.gz dist/SHA256SUMS; do
|
||||||
|
curl --fail-with-body --silent --show-error \
|
||||||
|
--request PUT \
|
||||||
|
--header "Authorization: token $GITEA_TOKEN" \
|
||||||
|
--upload-file "$package_file" \
|
||||||
|
"$package_url/$(basename "$package_file")"
|
||||||
|
done
|
||||||
|
|
||||||
|
curl --fail-with-body --silent --show-error \
|
||||||
|
--request POST \
|
||||||
|
--header "Authorization: token $GITEA_TOKEN" \
|
||||||
|
"$GITEA_SERVER_URL/api/v1/packages/$GITEA_OWNER/generic/bdrclone/-/link/$repository_name"
|
||||||
|
|||||||
Reference in New Issue
Block a user