Skip to content

4.5.1

4.5.1 #98

Workflow file for this run

name: Release Tasks
on:
release:
types:
- published
- edited
- deleted
- released # See: https://github.community/t5/GitHub-API-Development-and/Webhook-ReleaseEvent-prerelease-gt-release-notification/m-p/22612
concurrency: release_tasks
jobs:
trigger-site-update:
name: 'Trigger Site Update'
permissions:
contents: read
runs-on: ubuntu-latest
if: (github.repository == 'Warzone2100/warzone2100')
environment: update_dispatch
# For this job to work, the following secrets must be set in the 'update_dispatch' environment:
# SITE_DISPATCH_ACCESS_TOKEN
# DEPLOY_DISPATCH_ACCESS_TOKEN
steps:
- name: 'Trigger wz2100.net update'
run: |
curl -X POST https://api.github.com/repos/Warzone2100/wz2100.net/dispatches \
-H 'Accept: application/vnd.github.everest-preview+json' \
-u ${{ secrets.SITE_DISPATCH_ACCESS_TOKEN }} \
--data '{"event_type": "github_release_update", "client_payload": { "repository": "'"$GITHUB_REPOSITORY"'" }}'
- name: 'Trigger updates.json update'
run: |
curl -X POST https://api.github.com/repos/Warzone2100/update-data/dispatches \
-H 'Accept: application/vnd.github.everest-preview+json' \
-u ${{ secrets.SITE_DISPATCH_ACCESS_TOKEN }} \
--data '{"event_type": "github_release_update", "client_payload": { "repository": "'"$GITHUB_REPOSITORY"'" }}'
- name: 'Trigger itch.io deployment'
run: |
curl -X POST https://api.github.com/repos/Warzone2100/itch-build/dispatches \
-H 'Accept: application/vnd.github.everest-preview+json' \
-u ${{ secrets.DEPLOY_DISPATCH_ACCESS_TOKEN }} \
--data '{"event_type": "github_release_update", "client_payload": { "repository": "'"$GITHUB_REPOSITORY"'" }}'
- name: 'Trigger MSIX deployment'
if: (github.event.action == 'published') || (github.event.action == 'released')
run: |
curl -X POST https://api.github.com/repos/wz-packaging/wz-ms-packaging/dispatches \
-H 'Accept: application/vnd.github.everest-preview+json' \
-u ${{ secrets.DEPLOY_DISPATCH_ACCESS_TOKEN }} \
--data '{"event_type": "github_release_update", "client_payload": { "repository": "'"$GITHUB_REPOSITORY"'" }}'
webedition-release-commit:
name: 'Commit Web Edition Release'
permissions:
contents: read
runs-on: ubuntu-latest
if: ((github.event.action == 'published') || (github.event.action == 'released')) && (github.repository == 'Warzone2100/warzone2100')
environment: webedition_release_management
# The following must be set in the 'webedition_release_management' environment:
# Secret: WZ_WEB_BUILD_RELEASE_MANAGEMENT_TOKEN
# Variable: WZ_WEB_BUILD_RELEASE_MANAGEMENT_API_URL
steps:
- name: 'Get actual latest release from GH'
env:
GH_TOKEN: ${{ github.token }}
run: |
# Get the actual latest release from GitHub directly
# (which could differ from the release associated with this event, if someone publishes some older versions as GitHub Releases at some point)
# (this also ensure that prereleases - which won't get set as the "latest" release - aren't set as /latest/)
WZ_LATEST_RELEASE_TAG="$(gh --repo $GITHUB_REPOSITORY release view --json 'tagName' --jq '.tagName')"
echo "WZ_LATEST_RELEASE_TAG=${WZ_LATEST_RELEASE_TAG}"
echo "WZ_LATEST_RELEASE_TAG=${WZ_LATEST_RELEASE_TAG}" >> $GITHUB_ENV
- name: 'Set play.wz2100.net/latest/ to the latest release'
env:
WZ_WEB_BUILD_RELEASE_MANAGEMENT_TOKEN: ${{ secrets.WZ_WEB_BUILD_RELEASE_MANAGEMENT_TOKEN }}
WZ_WEB_BUILD_RELEASE_MANAGEMENT_API_URL: ${{ vars.WZ_WEB_BUILD_RELEASE_MANAGEMENT_API_URL }}
run: |
curl -i -X POST "${WZ_WEB_BUILD_RELEASE_MANAGEMENT_API_URL}" \
--data "token=${WZ_WEB_BUILD_RELEASE_MANAGEMENT_TOKEN}&setlatest=${WZ_LATEST_RELEASE_TAG}"
- name: 'Purge Cloudflare Cache'
if: success() && (steps.publishpages.outputs.PROCESS_DEPLOYMENT == 'true')
env:
CLOUDFLARE_ZONE: ${{ secrets.CLOUDFLARE_WZ2100_ZONE }}
CLOUDFLARE_CACHEPURGE_TOKEN: ${{ secrets.CLOUDFLARE_WZ2100_CACHEPURGE_TOKEN }}
run: |
curl -X POST "https://api.cloudflare.com/client/v4/zones/${CLOUDFLARE_ZONE}/purge_cache" \
-H "Authorization: Bearer ${CLOUDFLARE_CACHEPURGE_TOKEN}" \
-H "Content-Type: application/json" \
--data '{"purge_everything":true}'
sentry-release-commit-info:
name: 'Upload Release Commit Info'
permissions:
contents: read
runs-on: ubuntu-latest
if: ((github.event.action == 'published') || (github.event.action == 'released')) && (github.repository == 'Warzone2100/warzone2100')
environment: upload_symbols
# For this job to work, the following secrets must be set in the 'upload_symbols' environment:
# SENTRY_AUTH_TOKEN
steps:
- name: Prep Environment
run: |
mkdir empty-folder
- uses: actions/checkout@v4
with:
fetch-depth: 0
path: 'src'
- name: Prepare Git Repo for autorevision
working-directory: '${{ github.workspace }}/src'
run: cmake -P .ci/githubactions/prepare_git_repo.cmake
- name: 'List tags'
working-directory: '${{ github.workspace }}/src'
run: |
git tag --list
- name: 'Collect release info'
working-directory: '${{ github.workspace }}/src'
run: |
CURRENT_TAG="${GITHUB_REF#refs/tags/}"
echo "CURRENT_TAG=${CURRENT_TAG}"
SENTRY_VERSION="warzone2100@${CURRENT_TAG}"
echo "SENTRY_VERSION=${SENTRY_VERSION}"
# Get commit of prior release tag
PRIOR_TAG="$(git describe --abbrev=0 ${GITHUB_REF}^)"
echo "PRIOR_TAG=${PRIOR_TAG}"
PRIOR_TAG_COMMIT="$(git rev-list -n 1 "refs/tags/${PRIOR_TAG}")"
echo "PRIOR_TAG_COMMIT=${PRIOR_TAG_COMMIT}"
# Get commit of current release tag
CURRENT_TAG_COMMIT="$(git rev-list -n 1 "${GITHUB_REF}")"
echo "CURRENT_TAG_COMMIT=${CURRENT_TAG_COMMIT}"
echo "WZ_REPO_PATH=$(pwd)" >> $GITHUB_ENV
echo "SENTRY_VERSION=${SENTRY_VERSION}" >> $GITHUB_ENV
echo "PRIOR_TAG_COMMIT=${PRIOR_TAG_COMMIT}" >> $GITHUB_ENV
echo "CURRENT_TAG_COMMIT=${CURRENT_TAG_COMMIT}" >> $GITHUB_ENV
- name: 'Upload Sentry release info'
if: (github.repository == 'Warzone2100/warzone2100')
working-directory: '${{ github.workspace }}/empty-folder'
env:
SENTRY_AUTH_TOKEN: '${{ secrets.SENTRY_AUTH_TOKEN }}'
SENTRY_ORG: 'warzone2100'
run: |
if [[ -z "${SENTRY_AUTH_TOKEN}" ]]; then
echo "No SENTRY_AUTH_TOKEN - skipping"
exit 0
fi
if [[ -z "${SENTRY_VERSION}" ]]; then
echo "No SENTRY_VERSION - skipping"
exit 0
fi
# Download sentry-cli
echo "::group::Downloading sentry-cli ..."
cmake -P "${WZ_REPO_PATH}/.ci/githubactions/FetchSentryCLI.cmake"
echo "Downloading sentry-cli ... Done"
echo "::endgroup::"
# Check if release already exists
echo "Checking if release exists: ${SENTRY_VERSION}"
if ! ./sentry-cli/sentry-cli releases info "${SENTRY_VERSION}" -q; then
# Create the release
echo "Creating the release: ${SENTRY_VERSION}"
./sentry-cli/sentry-cli releases new -p warzone2100 "${SENTRY_VERSION}" || echo "Failed to create the release?"
fi
# Associate commits with the release
echo "Associate commits with the release: ${SENTRY_VERSION}"
./sentry-cli/sentry-cli releases set-commits "${SENTRY_VERSION}" --commit "Warzone2100/warzone2100@${PRIOR_TAG_COMMIT}..${CURRENT_TAG_COMMIT}"