114 lines
3.8 KiB
YAML
114 lines
3.8 KiB
YAML
name: Build and Release
|
|
|
|
on:
|
|
push:
|
|
tags:
|
|
- 'v*'
|
|
|
|
jobs:
|
|
build-amd64:
|
|
runs-on: junkpile
|
|
steps:
|
|
- name: Checkout
|
|
run: |
|
|
git init
|
|
git remote add origin ${{ gitea.server_url }}/${{ gitea.repository }}.git
|
|
git fetch --depth=1 origin ${{ gitea.ref }}
|
|
git checkout FETCH_HEAD
|
|
|
|
- name: Build .deb
|
|
run: make deb
|
|
|
|
- name: Publish to apt registry
|
|
run: |
|
|
DEB=$(ls build/*.deb)
|
|
echo "Publishing ${DEB}..."
|
|
curl --fail -H "Authorization: token ${{ secrets.PACKAGES_TOKEN }}" \
|
|
--upload-file "${DEB}" \
|
|
"${{ gitea.server_url }}/api/packages/madcat-os/debian/pool/bookworm/main/upload"
|
|
|
|
- name: Upload to generic packages
|
|
run: |
|
|
DEB=$(ls build/*.deb)
|
|
FILENAME=$(basename "${DEB}")
|
|
curl --fail -X PUT \
|
|
-H "Authorization: token ${{ secrets.PACKAGES_TOKEN }}" \
|
|
--upload-file "${DEB}" \
|
|
"${{ gitea.server_url }}/api/packages/madcat-os/generic/madcat-caddy/${{ gitea.ref_name }}/${FILENAME}"
|
|
|
|
build-arm64:
|
|
runs-on: sin
|
|
steps:
|
|
- name: Checkout
|
|
run: |
|
|
git init
|
|
git remote add origin ${{ gitea.server_url }}/${{ gitea.repository }}.git
|
|
git fetch --depth=1 origin ${{ gitea.ref }}
|
|
git checkout FETCH_HEAD
|
|
|
|
- name: Build .deb
|
|
run: make deb
|
|
|
|
- name: Publish to apt registry
|
|
run: |
|
|
DEB=$(ls build/*.deb)
|
|
echo "Publishing ${DEB}..."
|
|
curl --fail -H "Authorization: token ${{ secrets.PACKAGES_TOKEN }}" \
|
|
--upload-file "${DEB}" \
|
|
"${{ gitea.server_url }}/api/packages/madcat-os/debian/pool/bookworm/main/upload"
|
|
|
|
- name: Upload to generic packages
|
|
run: |
|
|
DEB=$(ls build/*.deb)
|
|
FILENAME=$(basename "${DEB}")
|
|
curl --fail -X PUT \
|
|
-H "Authorization: token ${{ secrets.PACKAGES_TOKEN }}" \
|
|
--upload-file "${DEB}" \
|
|
"${{ gitea.server_url }}/api/packages/madcat-os/generic/madcat-caddy/${{ gitea.ref_name }}/${FILENAME}"
|
|
|
|
release:
|
|
runs-on: junkpile
|
|
needs: [build-amd64, build-arm64]
|
|
steps:
|
|
- name: Download artifacts
|
|
run: |
|
|
mkdir -p artifacts
|
|
TAG="${{ gitea.ref_name }}"
|
|
VERSION="${TAG#v}"
|
|
for arch in amd64 arm64; do
|
|
FILENAME="madcat-caddy_${VERSION}_${arch}.deb"
|
|
echo "Downloading ${FILENAME}..."
|
|
curl --fail -fsSL \
|
|
-H "Authorization: token ${{ secrets.PACKAGES_TOKEN }}" \
|
|
-o "artifacts/${FILENAME}" \
|
|
"${{ gitea.server_url }}/api/packages/madcat-os/generic/madcat-caddy/${TAG}/${FILENAME}"
|
|
done
|
|
ls -la artifacts/
|
|
|
|
- name: Create release and attach assets
|
|
run: |
|
|
TAG="${{ gitea.ref_name }}"
|
|
API="${{ gitea.server_url }}/api/v1"
|
|
REPO="${{ gitea.repository }}"
|
|
TOKEN="${{ secrets.PACKAGES_TOKEN }}"
|
|
|
|
# Create release
|
|
RELEASE_ID=$(curl --fail -X POST \
|
|
-H "Authorization: token ${TOKEN}" \
|
|
-H "Content-Type: application/json" \
|
|
-d "{\"tag_name\":\"${TAG}\",\"name\":\"${TAG}\",\"draft\":false,\"prerelease\":false}" \
|
|
"${API}/repos/${REPO}/releases" | jq -r '.id')
|
|
echo "Created release ID: ${RELEASE_ID}"
|
|
|
|
# Attach .deb files
|
|
for deb in artifacts/*.deb; do
|
|
FILENAME=$(basename "${deb}")
|
|
echo "Attaching ${FILENAME}..."
|
|
curl --fail -X POST \
|
|
-H "Authorization: token ${TOKEN}" \
|
|
-F "attachment=@${deb}" \
|
|
"${API}/repos/${REPO}/releases/${RELEASE_ID}/assets?name=${FILENAME}"
|
|
echo ""
|
|
done
|
|
echo "Release ${TAG} published with all assets."
|