Added search by author #6960
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Snapcraft | |
on: | |
push: | |
branches-ignore: | |
- 'l10n_**' # Push events to translation service branches (that begin with "l10n_") | |
pull_request: | |
# Match all pull requests... | |
paths-ignore: | |
# Except some text-only files / documentation | |
- 'ChangeLog' | |
# Except those that only include changes to stats | |
- 'data/base/stats/**' | |
- 'data/mp/stats/**' | |
- 'data/mp/multiplay/script/functions/camTechEnabler.js' | |
# Linux-specific example scripts | |
- 'doc/hosting/linux_scripts/**' | |
# Support running after "Draft Tag Release" workflow completes, as part of automated release process | |
workflow_run: | |
workflows: ["Draft Tag Release"] | |
push: | |
tags: | |
- '*' | |
types: | |
- completed | |
jobs: | |
snapcraft: | |
strategy: | |
matrix: | |
include: | |
- name: "Snapcraft" | |
arch: "amd64" | |
name: '${{ matrix.name }}' | |
permissions: | |
contents: write # Needed to upload to releases | |
# needed to generate artifact attestations, see: https://docs.github.com/en/actions/security-guides/using-artifact-attestations-to-establish-provenance-for-builds | |
id-token: write | |
attestations: write | |
runs-on: ubuntu-20.04 # Use instead of ubuntu-latest until https://github.com/snapcore/action-build/issues/42 is resolved | |
if: "!contains(github.event.head_commit.message, '[ci skip]')" | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Configure Repo Checkout | |
id: checkout-config | |
env: | |
WORKFLOW_RUN_CONCLUSION: ${{ github.event.workflow_run.conclusion }} | |
WORKFLOW_RUN_HEAD_SHA: ${{ github.event.workflow_run.head_sha }} | |
run: | | |
. .ci/githubactions/checkout_config.sh | |
- name: Prepare Git Repo for autorevision | |
run: cmake -P .ci/githubactions/prepare_git_repo.cmake | |
- name: Init Git Submodules | |
run: git submodule update --init --recursive | |
- name: Compute build variables | |
run: | | |
. .ci/githubactions/export_build_output_desc.sh | |
echo "WZ_BUILD_DESC_IS_TAG=${WZ_BUILD_DESC_IS_TAG}" >> $GITHUB_ENV | |
echo "WZ_BUILD_DESC_PREFIX=${WZ_BUILD_DESC_PREFIX}" >> $GITHUB_ENV | |
WZ_OUTPUT_NAME_SUFFIX="" | |
WZ_NAME_SUFFIX="" | |
if [ "$WZ_BUILD_DESC_IS_TAG" == "false" ]; then | |
WZ_OUTPUT_NAME_SUFFIX="_$(echo "${WZ_BUILD_DESC_PREFIX}" | sed 's/[^a-zA-Z0-9\.]/_/g')" | |
WZ_NAME_SUFFIX=" ($(echo "${WZ_BUILD_DESC_PREFIX}" | sed 's/[^a-zA-Z0-9\.]/_/g'))" | |
fi | |
echo "WZ_OUTPUT_NAME_SUFFIX=${WZ_OUTPUT_NAME_SUFFIX}" | |
echo "WZ_OUTPUT_NAME_SUFFIX=${WZ_OUTPUT_NAME_SUFFIX}" >> $GITHUB_ENV | |
echo "WZ_NAME_SUFFIX=${WZ_NAME_SUFFIX}" >> $GITHUB_ENV | |
WZ_DISTRIBUTOR="UNKNOWN" | |
if [ "${GITHUB_REPOSITORY}" == "Warzone2100/warzone2100" ]; then | |
WZ_DISTRIBUTOR="wz2100.net" | |
fi | |
echo "WZ_DISTRIBUTOR=${WZ_DISTRIBUTOR}" | |
echo "WZ_DISTRIBUTOR=${WZ_DISTRIBUTOR}" >> $GITHUB_ENV | |
- name: Prepare to build .SNAP | |
run: | | |
WZ_PACKAGE_VAR_OVERRIDES="" | |
WZ_SHORT_SHA=$(echo "${GITHUB_SHA}" | head -c 7) | |
if [ "$WZ_BUILD_DESC_IS_TAG" == "false" ]; then | |
SNAP_VERSION_SAFE_DESC_PREFIX=$(echo "${WZ_BUILD_DESC_PREFIX}" | sed 's/[^a-zA-Z0-9]/~/g') | |
WZ_PACKAGE_VAR_OVERRIDES="-D WZ_DEVELOPMENT_BUILD=ON" | |
fi | |
WZ_SNAP_PACKAGE_NAME=$(echo "warzone2100${WZ_OUTPUT_NAME_SUFFIX}" | sed 's/[^a-zA-Z0-9\.\+\-]/-/g') | |
cat > .snapenv <<EOENV | |
CI=true | |
GITHUB_WORKFLOW="$GITHUB_WORKFLOW" | |
GITHUB_ACTIONS="$GITHUB_ACTIONS" | |
GITHUB_REPOSITORY="$GITHUB_REPOSITORY" | |
GITHUB_WORKSPACE="$GITHUB_WORKSPACE" | |
GITHUB_SHA="$WZ_GITHUB_SHA" | |
GITHUB_REF="$WZ_GITHUB_REF" | |
GITHUB_HEAD_REF="$WZ_GITHUB_HEAD_REF" | |
GITHUB_BASE_REF="$WZ_GITHUB_BASE_REF" | |
MAKEFLAGS="$MAKEFLAGS" | |
SNAP_VERSION_SAFE_DESC_PREFIX="$SNAP_VERSION_SAFE_DESC_PREFIX" | |
WZ_SHORT_SHA="$WZ_SHORT_SHA" | |
WZ_PACKAGE_VAR_OVERRIDES="$WZ_PACKAGE_VAR_OVERRIDES" | |
WZ_SNAP_PACKAGE_NAME="$WZ_SNAP_PACKAGE_NAME" | |
EOENV | |
- name: Build .SNAP | |
id: snapcraft | |
uses: snapcore/action-build@v1 | |
- name: Gather .SNAP | |
run: | | |
OUTPUT_DIR="${HOME}/output" | |
echo "OUTPUT_DIR=${OUTPUT_DIR}" | |
echo "OUTPUT_DIR=${OUTPUT_DIR}" >> $GITHUB_ENV | |
mkdir -p "${OUTPUT_DIR}" | |
OUTPUT_FILE_NAME="warzone2100_linux_${{ matrix.arch }}.snap" | |
cp "${{ steps.snapcraft.outputs.snap }}" "${OUTPUT_DIR}/${OUTPUT_FILE_NAME}" | |
echo "Generated .snap: \"${OUTPUT_FILE_NAME}\"" | |
echo " -> SHA512: $(sha512sum "${OUTPUT_DIR}/${OUTPUT_FILE_NAME}")" | |
echo " -> Size (bytes): $(stat -c %s "${OUTPUT_DIR}/${OUTPUT_FILE_NAME}")" | |
echo "WZ_FULL_OUTPUT_SNAP_PATH=${OUTPUT_DIR}/${OUTPUT_FILE_NAME}" >> $GITHUB_ENV | |
- uses: actions/upload-artifact@v4 | |
if: success() | |
with: | |
name: 'warzone2100_linux_${{ matrix.arch }}_snap' | |
path: '${{ env.WZ_FULL_OUTPUT_SNAP_PATH }}' | |
if-no-files-found: 'error' | |
- name: Generate artifact attestation | |
# Run on push to master branch (development build), or tag release automation build | |
if: success() && ((github.event_name == 'push' && github.ref == 'refs/heads/master') || (github.event_name == 'workflow_run' && github.event.workflow_run.name == 'Draft Tag Release')) | |
uses: actions/attest-build-provenance@v1 | |
continue-on-error: true | |
with: | |
subject-path: '${{ env.WZ_FULL_OUTPUT_SNAP_PATH }}' | |
- name: Upload artifact to release | |
if: success() && (github.event_name == 'workflow_run' && github.event.workflow_run.name == 'Draft Tag Release') | |
run: | | |
SOURCE_TAG="${WZ_GITHUB_REF#refs/tags/}" | |
gh release upload "${SOURCE_TAG}" "${{ env.WZ_FULL_OUTPUT_SNAP_PATH }}" | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
GH_REPO: ${{ github.repository }} | |
WZ_GITHUB_REF: ${{ steps.checkout-config.outputs.WZ_GITHUB_REF }} |