This commit is contained in:
commit
db512f7633
8 files changed
+212
No files matched your search
@@ -0,0 +1,72 @@
|
||||
name: Build and publish gitea-runner via local runner
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
version:
|
||||
description: "Upstream version, without the v (e.g. 5.1.1)"
|
||||
required: true
|
||||
type: string
|
||||
revision:
|
||||
description: "Packaging revision"
|
||||
required: false
|
||||
default: "1"
|
||||
type: string
|
||||
|
||||
env:
|
||||
DISTRIBUTION: any
|
||||
COMPONENT: main
|
||||
|
||||
jobs:
|
||||
build-and-publish:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Validate inputs
|
||||
env:
|
||||
VERSION: ${{ inputs.version }}
|
||||
REVISION: ${{ inputs.revision }}
|
||||
run: |
|
||||
# Inputs may come from an external service, so never trust them blindly
|
||||
echo "$VERSION" | grep -Eq '^[0-9]+(\.[0-9]+)*$' || { echo "Bad version"; exit 1; }
|
||||
echo "$REVISION" | grep -Eq '^[0-9]+$' || { echo "Bad revision"; exit 1; }
|
||||
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Install build tools
|
||||
run: |
|
||||
if ! command -v make >/dev/null || ! command -v curl >/dev/null; then
|
||||
apt-get update && apt-get install -y make curl
|
||||
fi
|
||||
|
||||
- name: Build package
|
||||
env:
|
||||
VERSION: ${{ inputs.version }}
|
||||
REVISION: ${{ inputs.revision }}
|
||||
run: make VERSION="$VERSION" REVISION="$REVISION"
|
||||
|
||||
- name: Publish to Gitea package registry
|
||||
env:
|
||||
VERSION: ${{ inputs.version }}
|
||||
REVISION: ${{ inputs.revision }}
|
||||
UPLOADER: ${{ secrets.PACKAGE_UPLOAD_USERNAME }}
|
||||
TOKEN: ${{ secrets.PACKAGE_UPLOAD_TOKEN }}
|
||||
OWNER: ${{ GITHUB_REPOSITORY_OWNER }}
|
||||
SERVER: ${{ GITHUB_SERVER_URL }}
|
||||
run: |
|
||||
DEB="build/gitea-runner_${VERSION}-${REVISION}_amd64.deb"
|
||||
CODE=$(curl -sS -o /tmp/resp -w '%{http_code}' \
|
||||
--user "${UPLOADER}:${TOKEN}" \
|
||||
--upload-file "$DEB" \
|
||||
"${SERVER}/api/packages/${OWNER}/debian/pool/${DISTRIBUTION}/${COMPONENT}/upload")
|
||||
cat /tmp/resp; echo
|
||||
case "$CODE" in
|
||||
201) echo "Published $DEB" ;;
|
||||
409) echo "This version/revision already exists; bump REVISION"; exit 1 ;;
|
||||
*) echo "Upload failed with HTTP $CODE"; exit 1 ;;
|
||||
esac
|
||||
|
||||
- name: Keep the .deb as a workflow artifact
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: gitea-runner-deb
|
||||
path: build/*.deb
|
||||
Reference in new issue
Block a user