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 run: make deb - name: Publish env: TOKEN: ${{ secrets.PACKAGES_TOKEN }} TAG: ${{ gitea.ref_name }} API: ${{ gitea.server_url }}/api/v1 REPO: ${{ gitea.repository }} PKG_URL: ${{ gitea.server_url }}/api/packages/madcat-os/debian/pool/bookworm/main/upload run: | DEB=$(ls build/*.deb) FILENAME=$(basename "${DEB}") echo "::group::apt upload" curl --fail -sS -H "Authorization: token ${TOKEN}" --upload-file "${DEB}" "${PKG_URL}" echo "" echo "::endgroup::" echo "::group::release" OLD_ID=$(curl -sS -H "Authorization: token ${TOKEN}" "${API}/repos/${REPO}/releases/tags/${TAG}" | jq -r 'if .id then .id else empty end' || true) test -n "${OLD_ID}" && curl -sS -X DELETE -H "Authorization: token ${TOKEN}" "${API}/repos/${REPO}/releases/${OLD_ID}" || true RELEASE_ID=$(curl -sS -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 "Release: ${RELEASE_ID}" curl --fail -sS -X POST -H "Authorization: token ${TOKEN}" -F "attachment=@${DEB}" "${API}/repos/${REPO}/releases/${RELEASE_ID}/assets?name=${FILENAME}" > /dev/null 2>&1 echo "::endgroup::" echo "amd64 done" 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 run: make deb - name: Publish env: TOKEN: ${{ secrets.PACKAGES_TOKEN }} TAG: ${{ gitea.ref_name }} API: ${{ gitea.server_url }}/api/v1 REPO: ${{ gitea.repository }} PKG_URL: ${{ gitea.server_url }}/api/packages/madcat-os/debian/pool/bookworm/main/upload run: | DEB=$(ls build/*.deb) FILENAME=$(basename "${DEB}") echo "::group::apt upload" curl --fail -sS -H "Authorization: token ${TOKEN}" --upload-file "${DEB}" "${PKG_URL}" echo "" echo "::endgroup::" echo "::group::attach to release" for i in $(seq 1 30); do RELEASE_ID=$(curl -sS -H "Authorization: token ${TOKEN}" "${API}/repos/${REPO}/releases/tags/${TAG}" | jq -r 'if .id then .id else empty end' || true) test -n "${RELEASE_ID}" && break echo " waiting... ${i}/30" sleep 10 done if [ -z "${RELEASE_ID}" ]; then RELEASE_ID=$(curl -sS -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') fi echo "Release: ${RELEASE_ID}" curl --fail -sS -X POST -H "Authorization: token ${TOKEN}" -F "attachment=@${DEB}" "${API}/repos/${REPO}/releases/${RELEASE_ID}/assets?name=${FILENAME}" > /dev/null 2>&1 echo "::endgroup::" echo "arm64 done"