name: build-releases on: workflow_dispatch: inputs: version: description: 'Tag to build and package (e.g. v4.9)' required: true title: description: 'Title for the release (unused on Gitea workflow)' required: false default: '' description: description: 'Description for the release (unused on Gitea workflow)' required: false default: '' jobs: release-packages: name: Build Linux/macOS/Windows archives runs-on: ubuntu-24.04 timeout-minutes: 360 env: P2POOL_VERSION: ${{ github.event.inputs.version }} steps: - name: Install dependencies run: | sudo apt-get update sudo apt-get install -y git build-essential cmake libuv1-dev libzmq3-dev libsodium-dev libpgm-dev libnorm-dev libgss-dev libcurl4-openssl-dev libidn2-0-dev xz-utils docker.io python3 jq - name: Checkout repository uses: actions/checkout@v4 with: repository: ${{ github.repository }} server_url: ${{ github.server_url }} token: ${{ secrets.GITEA_TOKEN }} fetch-depth: 0 submodules: recursive - name: Ensure version is provided shell: bash run: | if [ -z "${P2POOL_VERSION}" ]; then echo "P2POOL_VERSION is empty. Provide the version input when dispatching." exit 1 fi echo "Building release for ${P2POOL_VERSION}" - name: Ensure Docker is running run: | sudo systemctl start docker || sudo service docker start || true docker info - name: Build base toolchain image shell: bash run: | set -euo pipefail cd scripts/release/images/ubuntu ./build.sh - name: Build Linux x64 release shell: bash run: scripts/release/linux_x64/build.sh "${P2POOL_VERSION}" - name: Build macOS aarch64 release shell: bash run: scripts/release/macos_aarch64/build.sh "${P2POOL_VERSION}" - name: Build Windows x64 release shell: bash run: scripts/release/windows_x64/build.sh "${P2POOL_VERSION}" - name: Generate checksums shell: bash run: | set -euo pipefail cd scripts/release ./gen_sums.sh - name: Create Gitea release and upload assets env: VERSION: ${{ env.P2POOL_VERSION }} TOKEN: ${{ secrets.GITEA_TOKEN }} API_URL: ${{ github.api_url }} REPOSITORY: ${{ github.repository }} run: | set -euo pipefail if [ -z "${TOKEN:-}" ]; then echo "No GITEA_TOKEN available; cannot create release." exit 1 fi api="${API_URL:-${GITHUB_API_URL:-}}" if [ -z "$api" ]; then echo "API URL not provided; set GITEA_TOKEN and ensure API URL env is available." exit 0 fi release_payload=$(cat <<'EOF' { "tag_name": "<>", "target_commitish": "<>", "name": "<>", "body": "Release <>", "draft": false, "prerelease": false } EOF ) release_payload="${release_payload//<>/${VERSION}}" echo "Creating release ${VERSION} via ${api}/repos/${REPOSITORY}/releases" response=$(curl -sS -X POST \ -H "Authorization: token ${TOKEN}" \ -H "Content-Type: application/json" \ -d "${release_payload}" \ "${api}/repos/${REPOSITORY}/releases") release_id=$(python3 - <<'PY' import json,sys try: data=json.load(sys.stdin) rid=data.get("id") if rid: print(rid) except Exception: pass PY <<<"$response") if [ -z "$release_id" ]; then echo "Failed to create release; response:" echo "$response" exit 1 fi echo "Release created with id $release_id. Uploading assets..." for file in \ scripts/release/p2pool-${VERSION}-linux-x64.tar.gz \ scripts/release/p2pool-${VERSION}-macos-aarch64.tar.gz \ scripts/release/p2pool-${VERSION}-windows-x64.zip \ scripts/release/sha256sums.txt; do if [ ! -f "$file" ]; then echo "Missing asset $file; skipping upload." continue fi fname="$(basename "$file")" upload_url="${api}/repos/${REPOSITORY}/releases/${release_id}/assets?name=${fname}" echo "Uploading $fname" curl -sS -X POST \ -H "Authorization: token ${TOKEN}" \ -H "Content-Type: application/octet-stream" \ --data-binary @"$file" \ "$upload_url" done - name: Upload release artifacts uses: actions/upload-artifact@v4 with: name: p2pool-release-${{ env.P2POOL_VERSION }} path: | scripts/release/p2pool-${{ env.P2POOL_VERSION }}-linux-x64.tar.gz scripts/release/p2pool-${{ env.P2POOL_VERSION }}-macos-aarch64.tar.gz scripts/release/p2pool-${{ env.P2POOL_VERSION }}-windows-x64.zip scripts/release/sha256sums.txt