Files
p2pool-salvium/.github/workflows/build-releases.yml
2025-12-10 00:57:35 +01:00

118 lines
4.2 KiB
YAML

name: Build Releases
on:
workflow_dispatch:
inputs:
version:
description: 'Tag to build and create a release for (e.g. v4.9)'
required: true # Changed to true, as a version is required for a release
title:
description: 'Title for the release (defaults to version tag)'
required: false
default: ''
description:
description: 'Description for the release (supports Markdown)'
required: false
default: ''
env:
GIT_CONFIG_PARAMETERS: submodule.third_party/googleapis.update=none
jobs:
release-packages:
name: Build Linux/macOS/Windows archives
runs-on: [self-hosted, Linux, X64]
timeout-minutes: 360
env:
# This logic correctly gets the version from either the dispatch input or the tag name
P2POOL_VERSION: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.version || github.ref_name }}
P2POOL_BUILD_CACHE: /tmp/p2pool-buildx-cache
DOCKER_BUILDKIT: 1
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: recursive
- name: Ensure version is provided
shell: bash
run: |
if [ -z "${P2POOL_VERSION}" ]; then
echo "P2POOL_VERSION is empty. Trigger the workflow from a tag or provide the version input."
exit 1
fi
echo "Building release for ${P2POOL_VERSION}"
- name: Restore Docker build cache
uses: actions/cache@v3
with:
path: /tmp/p2pool-buildx-cache
key: p2pool-buildx-${{ runner.os }}-${{ env.P2POOL_VERSION }}
restore-keys: |
p2pool-buildx-${{ runner.os }}-
# This new step sets the title and body for the release
- name: Set Release Title and Body
id: set_release_vars
shell: bash
run: |
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
# Use dispatch inputs, with a fallback for the title
echo "title=${{ github.event.inputs.title || env.P2POOL_VERSION }}" >> $GITHUB_OUTPUT
echo "body=${{ github.event.inputs.description || 'No description provided.' }}" >> $GITHUB_OUTPUT
else
# Use tag name for title and a default body for tag pushes
echo "title=${{ env.P2POOL_VERSION }}" >> $GITHUB_OUTPUT
echo "body=Release for tag ${{ env.P2POOL_VERSION }}" >> $GITHUB_OUTPUT
fi
- 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
# This step replaces the old 'upload-artifact' step
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
# The tag_name this release will be associated with
tag_name: ${{ env.P2POOL_VERSION }}
# The title of the release (from the step above)
name: ${{ steps.set_release_vars.outputs.title }}
# The body/description of the release (from the step above)
body: ${{ steps.set_release_vars.outputs.body }}
# The files to upload as release assets
files: |
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
draft: false
prerelease: false
env:
# The GITHUB_TOKEN is required to create releases
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}