Skip to content

Update Vulkan SDK, vcpkg, etc #214

Update Vulkan SDK, vcpkg, etc

Update Vulkan SDK, vcpkg, etc #214

name: 'Snap Stable Config'
on:
# Needs several triggers:
# On tag push, this should run to "verify only" (i.e. *without* pushing it to the snap-stable-build repo)
# On regular push, this should run to "verify only" - if pertinent files are changed
# On release publish event, this should run *and* push to the snap-stable-build repo
# Permit manual triggering (that pushes to the snap-stable-build repo), in case snap config for the latest tagged release needs an update
push:
branches-ignore:
- 'l10n_**' # Push events to translation service branches (that begin with "l10n_")
paths: # Path filters are not evaluated for pushes to tags.
- '.github/workflows/generate_snap_stable_config.yml'
- '.ci/snap/**'
- '.snapcraft.yaml'
- 'pkg/snap/**'
# Sequence of patterns matched against refs/tags
tags:
- '*'
pull_request:
paths:
- '.github/workflows/generate_snap_stable_config.yml'
- '.ci/snap/**'
- '.snapcraft.yaml'
- 'pkg/snap/**'
release:
types:
- published
workflow_dispatch:
inputs:
git-ref:
description: Git Ref of Snapcraft Config (Optional)
required: false
concurrency: 'snap_stable_config_${{ github.event_name }}'
jobs:
generate_stable_snap_config:
name: 'Generate Snap Stable Config'
permissions:
contents: read
runs-on: ubuntu-20.04 # Use instead of ubuntu-latest until https://github.com/snapcore/action-build/issues/42 is resolved
steps:
- name: Generate Config
id: config
env:
GH_EVENT_NAME: '${{ github.event_name }}'
GH_EVENT_ACTION: '${{ github.event.action }}'
run: |
PUBLISH_CONFIG="false"
if [[ "${GH_EVENT_NAME}" == "release" ]] || [[ "${GH_EVENT_NAME}" == "workflow_dispatch" ]]; then
PUBLISH_CONFIG="true"
fi
echo "PUBLISH_CONFIG=${PUBLISH_CONFIG}" >> $GITHUB_OUTPUT
echo "PUBLISH_CONFIG=${PUBLISH_CONFIG}" >> $GITHUB_ENV
- name: Install Prereqs
run: |
sudo snap install yq
- name: Create working directories
id: preparefolders
run: |
mkdir -p "$HOME/data/github_releases_info"
echo "RELEASES_DATA=$HOME/data/github_releases_info" >> $GITHUB_OUTPUT
mkdir -p "$HOME/temp/github_releases_info"
echo "RELEASES_TEMP=$HOME/temp/github_releases_info" >> $GITHUB_OUTPUT
mkdir -p "${{ github.workspace }}/diff"
- name: Fetch latest GitHub Release info
uses: past-due/fetch-release-info@master
with:
github_repo: 'Warzone2100/warzone2100'
github_token: '${{ secrets.GITHUB_TOKEN }}'
calculate_asset_info: false
output_directory: '_dl/data/github_releases_info'
cache_directory: '_dl/temp/github_releases_info'
- name: Move Release info
run: |
cp -r --preserve=mode _dl/. $HOME/
sudo rm -rf _dl/
- name: Checkout (Latest)
if: github.event.inputs.git-ref == ''
uses: actions/checkout@v3
with:
path: warzone2100
submodules: recursive
persist-credentials: false
- name: Checkout (Custom Ref)
if: github.event.inputs.git-ref != ''
uses: actions/checkout@v3
with:
path: warzone2100
submodules: recursive
persist-credentials: false
ref: '${{ github.event.inputs.git-ref }}'
- name: Checkout snap-stable-build@master
uses: actions/checkout@v3
with:
repository: 'Warzone2100/snap-stable-build'
ref: master
path: snap-stable-build
- name: Generate Snap Stable Config
run: |
BASE_SNAPCRAFT_YAML=".snapcraft.yaml"
SNAPCRAFT_STABLE_OVERRIDES_YAML=".ci/snap/snapcraft-stable-overrides.yaml"
# Verify that required files / folders exist in main repo
cd "${GITHUB_WORKSPACE}/warzone2100"
if [[ ! -f "${BASE_SNAPCRAFT_YAML}" ]]; then
echo "Missing expected .snapcraft.yaml in warzone2100 repo"
exit 1
fi
if [ ! -d "pkg/snap" ]; then
echo "Missing expected pkg/snap folder in warzone2100 repo"
exit 1
fi
# Generate stable repo snapcraft.yml (that uses tags directly) from main repo snapcraft.yml via yq merge
yq eval-all 'select(fileIndex == 0) * select(fileIndex == 1)' "${BASE_SNAPCRAFT_YAML}" "${SNAPCRAFT_STABLE_OVERRIDES_YAML}" > "${GITHUB_WORKSPACE}/snap-stable-build/.snapcraft.yaml"
# Write .stable_tag file that contains the desired published tag
LATEST_GITHUB_RELEASE_TAG=$(cat "${{ steps.preparefolders.outputs.RELEASES_DATA }}/latest.json" | jq --raw-output '.tag_name')
echo "LATEST_GITHUB_RELEASE_TAG=${LATEST_GITHUB_RELEASE_TAG}"
if [ -z "${LATEST_GITHUB_RELEASE_TAG}" ]; then
echo "Failed - empty LATEST_GITHUB_RELEASE_TAG"
exit 1
fi
echo "${LATEST_GITHUB_RELEASE_TAG}" > "${GITHUB_WORKSPACE}/snap-stable-build/.stable_tag"
echo "LATEST_GITHUB_RELEASE_TAG=${LATEST_GITHUB_RELEASE_TAG}" >> $GITHUB_ENV
# Copy pkg/snap directory to pkg/snap in dest repo (overwriting old version)
rm -rf "${GITHUB_WORKSPACE}/snap-stable-build/pkg/snap"
mkdir -p "${GITHUB_WORKSPACE}/snap-stable-build/pkg/snap"
cp -r pkg/snap/. "${GITHUB_WORKSPACE}/snap-stable-build/pkg/snap"
- name: Debug output generated config
run: |
cat "${GITHUB_WORKSPACE}/snap-stable-build/.snapcraft.yaml"
- name: Commit changes to snap-stable-build
id: commit-snap-changes
working-directory: "${{ github.workspace }}/snap-stable-build"
run: |
git config user.name "GitHub Actions"
git config user.email "[email protected]"
git add -A
timestamp=$(date -u)
git commit -m "Snap stable build config for ${LATEST_GITHUB_RELEASE_TAG}" || { echo "PROCESS_DEPLOYMENT=false" >> $GITHUB_OUTPUT && exit 0; }
echo "PROCESS_DEPLOYMENT=true" >> $GITHUB_OUTPUT
# Get the new commit's SHA
NEW_COMMIT_SHA=$(git rev-parse --verify HEAD)
echo "NEW_COMMIT_SHA=${NEW_COMMIT_SHA}"
echo "GH_SNAPSTABLEBUILD_COMMIT_SHA=${NEW_COMMIT_SHA}" >> $GITHUB_OUTPUT
exit 0
- name: Snap build stable config (w/ most recent stable version)
id: build-stable
if: success() && (steps.commit-snap-changes.outputs.PROCESS_DEPLOYMENT == 'true')
continue-on-error: true
uses: snapcore/action-build@v1
with:
path: ${{ github.workspace }}/snap-stable-build
- name: Fail-check
id: fail-check
if: (steps.commit-snap-changes.outputs.PROCESS_DEPLOYMENT == 'true') && (steps.build-stable.outcome == 'failure' && steps.build-stable.conclusion == 'success')
run: |
# The build-stable step failed
if [[ "${PUBLISH_CONFIG}" != "false" ]] || [[ "${{ steps.config.outputs.PUBLISH_CONFIG }}" != "false" ]]; then
# The prior step had a FATAL error (because we're aiming to publish the config)
echo "::error ::Snap stable config failed to build (for: ${LATEST_GITHUB_RELEASE_TAG})"
exit 1
else
# Output a warning that this stable config will *not* work with the current stable release (but, presumably, with the next?)
echo "::warning ::Snap stable config failed to build (for: ${LATEST_GITHUB_RELEASE_TAG}). This may be acceptable, assuming it works for the next release."
fi
- name: Create diff artifact
id: create-diff
if: success() && (github.repository == 'Warzone2100/warzone2100') && (steps.commit-snap-changes.outputs.PROCESS_DEPLOYMENT == 'true')
env:
GH_SNAPSTABLEBUILD_COMMIT_SHA: '${{ steps.commit-snap-changes.outputs.GH_SNAPSTABLEBUILD_COMMIT_SHA }}'
working-directory: "${{ github.workspace }}/snap-stable-build"
run: |
git format-patch -k -1 --stdout "${GH_SNAPSTABLEBUILD_COMMIT_SHA}" > "${{ github.workspace }}/diff/snapstablebuild.diff"
DIFF_HASH="$(sha512sum "${{ github.workspace }}/diff/snapstablebuild.diff")"
echo "DIFF_HASH=${DIFF_HASH}" >> $GITHUB_OUTPUT
echo "snapstablebuild.diff (SHA512: ${DIFF_HASH}):"
cat "${{ github.workspace }}/diff/snapstablebuild.diff"
- name: Upload diff artifact
uses: actions/upload-artifact@v3
if: success() && (github.repository == 'Warzone2100/warzone2100') && (steps.commit-snap-changes.outputs.PROCESS_DEPLOYMENT == 'true')
with:
name: snap_stable_build_diff
path: '${{ github.workspace }}/diff/snapstablebuild.diff'
if-no-files-found: 'error'
deploy_stable_snap_config:
needs: generate_stable_snap_config
environment: snap_stable_build_deploy
name: 'Deploy Snap Stable Config'
permissions:
contents: read
runs-on: ubuntu-latest
if: (github.event_name == 'release') || (github.event_name == 'workflow_dispatch')
steps:
- name: Checkout snap-stable-build@master
uses: actions/checkout@v3
with:
repository: 'Warzone2100/snap-stable-build'
ref: master
path: snap-stable-build
ssh-key: '${{ secrets.SNAP_STABLE_BUILD_REPO_GH_DEPLOY_KEY }}'
- name: Fetch Snap Stable Config Changes
uses: actions/download-artifact@v3
with:
name: snap_stable_build_diff
path: '${{ github.workspace }}/diff'
- name: Apply Changes
working-directory: "${{ github.workspace }}/snap-stable-build"
run: |
git config user.name "GitHub Actions"
git config user.email "[email protected]"
git am -k "${{ github.workspace }}/diff/snapstablebuild.diff"
- name: Debug output generated config
run: |
cat "${GITHUB_WORKSPACE}/snap-stable-build/.snapcraft.yaml"
- name: Push config to snap-stable-build
if: success() && (github.repository == 'Warzone2100/warzone2100')
id: push-snap-changes
working-directory: "${{ github.workspace }}/snap-stable-build"
run: |
#git pull --rebase
# Push the new commit to the snap-stable-build repo
git push
echo "Done."
exit 0