forked from lthn/blockchain
76 lines
No EOL
2.9 KiB
YAML
76 lines
No EOL
2.9 KiB
YAML
# .github/actions/upload-artifacts/action.yml
|
|
name: 'Upload Artifacts'
|
|
description: 'Archives and uploads signed binaries to a GitHub release'
|
|
inputs:
|
|
chain-network:
|
|
required: true
|
|
description: 'The chain network name to use in filenames, mainnet or testnet'
|
|
assets:
|
|
description: "A \\n separated string list of filenames to archive; if asset is a abs path, it's respected"
|
|
required: false
|
|
asset-type:
|
|
required: true
|
|
description: 'The asset type: cli, gui, ANYTHING; used as a separator for different release packages for the same arch'
|
|
asset-directory:
|
|
required: true
|
|
description: "The directory where 7z's working dir will be set"
|
|
|
|
runs:
|
|
using: "composite"
|
|
steps:
|
|
- name: compute file name
|
|
id: asset
|
|
shell: bash
|
|
run: |
|
|
ARCH=${{ runner.arch }}
|
|
RUNNER_OS=${{ runner.os }}
|
|
LOWERCASE_ARCH=$(echo "$ARCH" | tr '[:upper:]' '[:lower:]')
|
|
TARGET_OS=$(echo "$RUNNER_OS" | tr '[:upper:]' '[:lower:]')
|
|
FILENAME="${{ inputs.chain-network }}-${{ inputs.asset-type }}-${TARGET_OS}-${LOWERCASE_ARCH}"
|
|
echo "key=$FILENAME" >> $GITHUB_OUTPUT
|
|
|
|
VERSION=$(grep '^BUILD_VERSION:=' Makefile | cut -d'=' -f2)
|
|
# Check if a version was found
|
|
if [ -z "$VERSION" ]; then
|
|
echo "Error: BUILD_VERSION could not be found in the Makefile." >&2
|
|
exit 1
|
|
fi
|
|
echo "version=${VERSION}" >> "$GITHUB_OUTPUT"
|
|
|
|
# Format the output to be a multi-line string.
|
|
# This is the correct way to pass a multi-line string in GITHUB_OUTPUT.
|
|
echo "paths<<EOF" >> "$GITHUB_OUTPUT"
|
|
|
|
# Iterate through each filename
|
|
echo "${{ inputs.assets }}" | while read -r file; do
|
|
if [[ -z "$file" ]]; then
|
|
continue
|
|
fi
|
|
# Check if the file is an absolute path
|
|
if [[ "$file" == /* ]] || [[ "$file" =~ ^[a-zA-Z]: ]]; then
|
|
FULL_PATH="$file"
|
|
else
|
|
# It's a relative path, so join it with the asset directory
|
|
if [[ "${{ runner.os }}" == "Windows" ]]; then
|
|
FULL_PATH="${{ inputs.asset-directory }}\\$file"
|
|
else
|
|
FULL_PATH="${{ inputs.asset-directory }}/$file"
|
|
fi
|
|
fi
|
|
echo "$FULL_PATH" >> "$GITHUB_OUTPUT"
|
|
done
|
|
echo "EOF" >> "$GITHUB_OUTPUT"
|
|
|
|
- name: Upload Artifacts
|
|
uses: actions/upload-artifact@v4.6.2
|
|
with:
|
|
name: ${{ steps.asset.outputs.key }}
|
|
path: ${{ steps.asset.outputs.paths }}
|
|
|
|
- name: Make Release
|
|
uses: softprops/action-gh-release@v2
|
|
with:
|
|
tag_name: ${{ steps.asset.outputs.version }}${{ inputs.chain-network == 'mainnet' && '' || '-pre' }}+${{ github.run_number }}
|
|
prerelease: ${{ contains(inputs.chain-network, 'testnet') }}
|
|
files: ${{ inputs.asset-directory }}/lethean-*
|
|
target_commitish: ${{ github.sha }} |