-
-
Notifications
You must be signed in to change notification settings - Fork 531
129 lines (124 loc) · 5.14 KB
/
CI_snapcraft.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
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'
# 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
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: 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 }}