mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-28 14:47:11 -07:00
don't depend on build path + cleanup + renaming
This commit is contained in:
+10
-10
@@ -171,7 +171,7 @@ done
|
||||
|
||||
# CI context (GitHub Actions provided environment variable)
|
||||
if [[ -z ${RUNNER_OS:-} ]]; then
|
||||
echo "::notice::RUNNER_OS (GitHub Actions CI environment variable) is not available and OS-specific configuration will be skipped."
|
||||
echo "::notice::RUNNER_OS (GitHub Actions CI environment variable) is not available and OS-specific build configuration will be skipped"
|
||||
fi
|
||||
|
||||
# Schema version consistency
|
||||
@@ -320,15 +320,15 @@ fi
|
||||
|
||||
# ccache
|
||||
if [[ $USE_CCACHE == 1 ]]; then
|
||||
echo "::group::Clear ccache stats"
|
||||
echo "::group::Show ccache configuration"
|
||||
ccache --version
|
||||
ccache --show-config
|
||||
echo "---"
|
||||
ccache --show-stats --verbose
|
||||
ccache --show-stats
|
||||
echo "---"
|
||||
ccache --zero-stats # zero former cache statistics (but not the configuration options or the cache itself)
|
||||
ccache --zero-stats
|
||||
echo "---"
|
||||
ccache --show-stats --verbose
|
||||
ccache --show-stats
|
||||
echo "::endgroup::"
|
||||
fi
|
||||
|
||||
@@ -360,10 +360,10 @@ if [[ $USE_CCACHE == 1 ]]; then
|
||||
echo "::endgroup::"
|
||||
fi
|
||||
|
||||
echo "::group::Show ccache stats"
|
||||
ccache --show-stats
|
||||
ccache --show-stats --verbose # too verbose?
|
||||
ccache --show-compression # helpful?
|
||||
echo "::group::Show ccache statistics"
|
||||
ccache --show-stats --verbose
|
||||
echo "---"
|
||||
ccache --show-compression
|
||||
echo "::endgroup::"
|
||||
|
||||
elif [[ -n $CCACHE_EVICTION_AGE ]]; then
|
||||
@@ -410,7 +410,7 @@ if [[ $MAKE_PACKAGE == 1 ]]; then
|
||||
|
||||
if [[ -n $PACKAGE_SUFFIX ]]; then
|
||||
echo "::group::Update package name"
|
||||
BUILD_DIR="$BUILD_DIR" .ci/name_build.sh "$PACKAGE_SUFFIX"
|
||||
.ci/name_build.sh "$PACKAGE_SUFFIX"
|
||||
echo "::endgroup::"
|
||||
fi
|
||||
fi
|
||||
|
||||
+42
-39
@@ -1,49 +1,52 @@
|
||||
#!/bin/bash
|
||||
# used by the ci to rename build artifacts
|
||||
# renames the file to [original name][SUFFIX].[original extension]
|
||||
# where SUFFIX is either available in the environment or as the first arg
|
||||
# expected to be run in the build directory unless BUILD_DIR is set
|
||||
# adds output to GITHUB_OUTPUT
|
||||
builddir="${BUILD_DIR:=.}"
|
||||
findrx="Cockatrice-*.*"
|
||||
#!/usr/bin/env bash
|
||||
|
||||
if [[ $1 ]]; then
|
||||
SUFFIX="$1"
|
||||
fi
|
||||
set -euo pipefail
|
||||
|
||||
# check env
|
||||
if [[ ! $SUFFIX ]]; then
|
||||
echo "::error file=$0::SUFFIX is missing"
|
||||
# Used by the CI build script to rename package artifacts
|
||||
#
|
||||
# Appends PACKAGE_SUFFIX to the package's filename
|
||||
# <package> = <filename><extension>
|
||||
# <package_new> = <filename><PACKAGE_SUFFIX><extension>
|
||||
# PACKAGE_SUFFIX must be passed as the first argument to the script
|
||||
# Adds output to GITHUB_OUTPUT
|
||||
#
|
||||
# Expected to be run in the repository root where CPack executes from and places its output binary
|
||||
# Expects a single binary for package_pattern and picks the first match
|
||||
# Expects <extension> to be e.g. ".dmg", ".deb" or ".exe" (".tar.gz" etc. with more than one dot will break)
|
||||
|
||||
# Initialize PACKAGE_SUFFIX from positional argument
|
||||
PACKAGE_SUFFIX="${1:-}"
|
||||
|
||||
# Check variable
|
||||
if [[ -z $PACKAGE_SUFFIX ]]; then
|
||||
echo "::error file=$0::Missing required argument: PACKAGE_SUFFIX"
|
||||
exit 2
|
||||
fi
|
||||
|
||||
set -e
|
||||
package_pattern="Cockatrice-*.*"
|
||||
|
||||
# find file
|
||||
found="$(find "$builddir" -maxdepth 1 -type f -name "$findrx" -print -quit)"
|
||||
path="${found%/*}" # remove all including first "/" from right side
|
||||
file="${found##*/}" # remove all including last "/" from left side
|
||||
if [[ ! $file ]]; then
|
||||
echo "::error file=$0::could not find package"
|
||||
exit 1
|
||||
fi
|
||||
oldpwd="$PWD"
|
||||
if ! cd "$path"; then
|
||||
echo "::error file=$0::could not get file path"
|
||||
# Find package in current directory
|
||||
package_path="$(find "$PWD" -maxdepth 1 -type f -name "$package_pattern" -print -quit)"
|
||||
|
||||
if [[ -z "$package_path" ]]; then
|
||||
echo "::error file=$0::Could not find package"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# set filename
|
||||
name="${file%.*}" # remove all including first "." from right side
|
||||
new_name="$name$SUFFIX"
|
||||
extension="${file##*.}" # remove all including last "." from left side
|
||||
filename="$new_name.$extension"
|
||||
echo "renaming '$file' to '$filename'"
|
||||
mv "$file" "$filename"
|
||||
# <package> = <filename><extension>
|
||||
package="${package_path##*/}" # remove folder path (keep e.g. "Cockatrice-3.0.0.deb")
|
||||
filename="${package%.*}" # remove extension (keep e.g. "Cockatrice-3.0.0")
|
||||
extension=".${package##*.}" # remove filename (keep e.g. ".deb")
|
||||
|
||||
cd "$oldpwd"
|
||||
relative_path="$path/$filename"
|
||||
ls -l "$relative_path"
|
||||
echo "path=$relative_path" >>"$GITHUB_OUTPUT"
|
||||
echo "name=$new_name" >>"$GITHUB_OUTPUT"
|
||||
echo "fullname=$filename" >>"$GITHUB_OUTPUT"
|
||||
# Rename package (build artifact)
|
||||
filename_new="$filename$PACKAGE_SUFFIX"
|
||||
package_new="$filename_new$extension"
|
||||
package_path_new="$PWD/$package_new"
|
||||
|
||||
echo "Renaming '$package' to '$package_new'"
|
||||
mv "$package_path" "$package_path_new"
|
||||
du -h "$package_path_new"
|
||||
|
||||
echo "package_path=$package_path_new" >>"$GITHUB_OUTPUT"
|
||||
echo "package=$package_new" >>"$GITHUB_OUTPUT"
|
||||
echo "filename=$filename_new" >>"$GITHUB_OUTPUT"
|
||||
|
||||
@@ -227,18 +227,18 @@ jobs:
|
||||
with:
|
||||
archive: false
|
||||
if-no-files-found: error
|
||||
path: ${{ steps.build.outputs.path }}
|
||||
path: ${{ steps.build.outputs.package_path }}
|
||||
|
||||
- name: "Upload to release"
|
||||
id: upload_release
|
||||
if: matrix.package != 'skip' && needs.configure.outputs.tag != null
|
||||
shell: bash
|
||||
env:
|
||||
asset_name: ${{ steps.build.outputs.fullname }}
|
||||
asset_path: ${{ steps.build.outputs.path }}
|
||||
package: ${{ steps.build.outputs.package }}
|
||||
package_path: ${{ steps.build.outputs.package_path }}
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
tag_name: ${{ needs.configure.outputs.tag }}
|
||||
run: gh release upload "$tag_name" "$asset_path#$asset_name"
|
||||
run: gh release upload "$tag_name" "$package_path#$package"
|
||||
|
||||
- name: "Attest binary provenance"
|
||||
id: attestation
|
||||
@@ -246,15 +246,15 @@ jobs:
|
||||
uses: actions/attest@v4
|
||||
with:
|
||||
show-summary: false
|
||||
subject-path: ${{ steps.build.outputs.path }}
|
||||
subject-path: ${{ steps.build.outputs.package_path }}
|
||||
|
||||
- name: "Verify binary attestation"
|
||||
if: steps.attestation.outcome == 'success'
|
||||
shell: bash
|
||||
env:
|
||||
BUILD_PATH: ${{ steps.build.outputs.path }}
|
||||
PACKAGE_PATH: ${{ steps.build.outputs.package_path }}
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
run: gh attestation verify "$BUILD_PATH" --repo Cockatrice/Cockatrice
|
||||
run: gh attestation verify "$PACKAGE_PATH" --repo Cockatrice/Cockatrice
|
||||
|
||||
build-vcpkg:
|
||||
strategy:
|
||||
@@ -475,20 +475,20 @@ jobs:
|
||||
if: matrix.os == 'macOS' && matrix.make_package && needs.configure.outputs.tag != null
|
||||
id: sign_macos
|
||||
env:
|
||||
BUILD_PATH: ${{ steps.build.outputs.path }}
|
||||
PACKAGE_PATH: ${{ steps.build.outputs.package_path }}
|
||||
MACOS_CERTIFICATE_NAME: ${{ secrets.PROD_MACOS_CERTIFICATE_NAME }}
|
||||
MACOS_CI_KEYCHAIN_PWD: ${{ secrets.PROD_MACOS_CI_KEYCHAIN_PWD }}
|
||||
run: |
|
||||
if [[ -n "$MACOS_CERTIFICATE_NAME" ]]
|
||||
then
|
||||
security unlock-keychain -p "$MACOS_CI_KEYCHAIN_PWD" build.keychain
|
||||
/usr/bin/codesign --sign="$MACOS_CERTIFICATE_NAME" --entitlements=".ci/macos.entitlements" --options=runtime --force --deep --timestamp --verbose "$BUILD_PATH"
|
||||
/usr/bin/codesign --sign="$MACOS_CERTIFICATE_NAME" --entitlements=".ci/macos.entitlements" --options=runtime --force --deep --timestamp --verbose "$PACKAGE_PATH"
|
||||
fi
|
||||
|
||||
- name: "[macOS] Notarize app bundle"
|
||||
if: matrix.os == 'macOS' && steps.sign_macos.outcome == 'success'
|
||||
env:
|
||||
BUILD_PATH: ${{ steps.build.outputs.path }}
|
||||
PACKAGE_PATH: ${{ steps.build.outputs.package_path }}
|
||||
MACOS_NOTARIZATION_APPLE_ID: ${{ secrets.PROD_MACOS_NOTARIZATION_APPLE_ID }}
|
||||
MACOS_NOTARIZATION_PWD: ${{ secrets.PROD_MACOS_NOTARIZATION_PWD }}
|
||||
MACOS_NOTARIZATION_TEAM_ID: ${{ secrets.PROD_MACOS_NOTARIZATION_TEAM_ID }}
|
||||
@@ -503,7 +503,7 @@ jobs:
|
||||
# Therefore, we create a zip file containing our app bundle, so that we can send it to the
|
||||
# notarization service
|
||||
echo "Creating temp notarization archive"
|
||||
ditto -c -k --keepParent "$BUILD_PATH" "notarization.zip"
|
||||
ditto -c -k --keepParent "$PACKAGE_PATH" "notarization.zip"
|
||||
|
||||
# Here we send the notarization request to the Apple's Notarization service, waiting for the result.
|
||||
# This typically takes a few seconds inside a CI environment, but it might take more depending on the App
|
||||
@@ -515,7 +515,7 @@ jobs:
|
||||
# Finally, we need to "attach the staple" to our executable, which will allow our app to be
|
||||
# validated by macOS even when an internet connection is not available.
|
||||
echo "Attach staple"
|
||||
xcrun stapler staple "$BUILD_PATH"
|
||||
xcrun stapler staple "$PACKAGE_PATH"
|
||||
fi
|
||||
|
||||
- name: "Upload artifact"
|
||||
@@ -525,14 +525,14 @@ jobs:
|
||||
with:
|
||||
archive: false
|
||||
if-no-files-found: error
|
||||
path: ${{ steps.build.outputs.path }}
|
||||
path: ${{ steps.build.outputs.package_path }}
|
||||
|
||||
- name: "[Windows] Upload PDBs (Program Databases)"
|
||||
if: matrix.os == 'Windows' && github.ref_type != 'tag'
|
||||
uses: actions/upload-artifact@v7
|
||||
with:
|
||||
if-no-files-found: error
|
||||
name: ${{ steps.build.outputs.name }}-PDBs
|
||||
name: ${{ steps.build.outputs.filename }}-PDBs
|
||||
path: |
|
||||
build/cockatrice/Release/*.pdb
|
||||
build/oracle/Release/*.pdb
|
||||
@@ -543,11 +543,11 @@ jobs:
|
||||
id: upload_release
|
||||
shell: bash
|
||||
env:
|
||||
asset_name: ${{ steps.build.outputs.fullname }}
|
||||
asset_path: ${{ steps.build.outputs.path }}
|
||||
package: ${{ steps.build.outputs.package }}
|
||||
package_path: ${{ steps.build.outputs.package_path }}
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
tag_name: ${{ needs.configure.outputs.tag }}
|
||||
run: gh release upload "$tag_name" "$asset_path#$asset_name"
|
||||
run: gh release upload "$tag_name" "$package_path#$package"
|
||||
|
||||
- name: "Attest binary provenance"
|
||||
if: steps.upload_release.outcome == 'success'
|
||||
@@ -555,12 +555,12 @@ jobs:
|
||||
uses: actions/attest@v4
|
||||
with:
|
||||
show-summary: false
|
||||
subject-path: ${{ steps.build.outputs.path }}
|
||||
subject-path: ${{ steps.build.outputs.package_path }}
|
||||
|
||||
- name: "Verify binary attestation"
|
||||
if: steps.attestation.outcome == 'success'
|
||||
shell: bash
|
||||
env:
|
||||
BUILD_PATH: ${{ steps.build.outputs.path }}
|
||||
PACKAGE_PATH: ${{ steps.build.outputs.package_path }}
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
run: gh attestation verify "$BUILD_PATH" --repo Cockatrice/Cockatrice
|
||||
run: gh attestation verify "$PACKAGE_PATH" --repo Cockatrice/Cockatrice
|
||||
|
||||
Reference in New Issue
Block a user