Skip to content

Commit 6f83f09

Browse files
authored
Merge pull request #3 from iBoonie/Builder-CI
Add action build
2 parents fb54158 + 6fc0088 commit 6f83f09

File tree

2 files changed

+234
-0
lines changed

2 files changed

+234
-0
lines changed

.github/workflows/ci-ext.yml

Lines changed: 164 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,164 @@
1+
name: Build Artifact
2+
3+
on:
4+
workflow_call:
5+
push:
6+
branches: [ main ]
7+
pull_request:
8+
branches: [ main ]
9+
10+
jobs:
11+
build:
12+
strategy:
13+
matrix:
14+
platform: [
15+
{ name: ubuntu-20.04, os: ubuntu-latest, containerImage: 'ubuntu:20.04', cc: clang-8, cxx: clang++-8 },
16+
{ name: windows-2019, os: windows-2019, cc: msvc },
17+
]
18+
19+
name: ${{ matrix.platform.name }} - ${{ matrix.platform.cc }}
20+
runs-on: ${{ matrix.platform.os }}
21+
container: ${{ matrix.platform.containerImage }}
22+
23+
env:
24+
# We currently only support tf2
25+
SDKS: '["tf2"]'
26+
MMSOURCE_VERSION: '1.12'
27+
SOURCEMOD_VERSION: '1.12'
28+
CACHE_PATH: 'cache'
29+
IN_CONTAINER: ${{ matrix.platform.containerImage != '' }}
30+
PYTHON_VERSION: '3.8'
31+
32+
steps:
33+
- name: Install Linux container dependencies
34+
if: startsWith(runner.os, 'Linux') && env.IN_CONTAINER == 'true'
35+
run: |
36+
apt-get update
37+
DEBIAN_FRONTEND=noninteractive TZ=Etc/UTC apt-get -y install tzdata
38+
apt-get install -y --no-install-recommends \
39+
sudo \
40+
git \
41+
curl \
42+
wget \
43+
zstd \
44+
build-essential \
45+
software-properties-common
46+
47+
- uses: actions/checkout@v4
48+
name: Repository checkout
49+
with:
50+
fetch-depth: 0
51+
submodules: true
52+
path: sendvaredit
53+
54+
- uses: actions/checkout@v4
55+
name: Sourcemod checkout
56+
with:
57+
repository: alliedmodders/sourcemod
58+
ref: ${{ env.SOURCEMOD_VERSION }}-dev
59+
submodules: true
60+
path: ${{ env.CACHE_PATH }}/sourcemod
61+
62+
- uses: actions/checkout@v4
63+
name: Metamod-Source checkout
64+
with:
65+
repository: alliedmodders/metamod-source
66+
ref: ${{ env.MMSOURCE_VERSION }}-dev
67+
path: ${{ env.CACHE_PATH }}/metamod
68+
69+
- uses: actions/checkout@v4
70+
name: AMBuild checkout
71+
with:
72+
repository: alliedmodders/ambuild
73+
ref: master
74+
path: ${{ env.CACHE_PATH }}/ambuild
75+
76+
- uses: actions/checkout@v4
77+
name: Checkout TF2 SDK
78+
with:
79+
repository: alliedmodders/hl2sdk
80+
ref: tf2
81+
path: ${{ env.CACHE_PATH }}/hl2sdk-tf2
82+
83+
- name: Setup Python ${{ env.PYTHON_VERSION }}
84+
uses: actions/setup-python@v5
85+
if: ${{ !(startsWith( runner.os, 'Linux' ) && env.IN_CONTAINER == 'true') }}
86+
with:
87+
python-version: ${{ env.PYTHON_VERSION }}
88+
89+
# The Setup Python action will fetch from a cached build of Python that is
90+
# built on newer distros which are not guaranteed to be compatible with older ones.
91+
# https://github.com/actions/setup-python/blob/main/docs/advanced-usage.md#using-setup-python-with-a-self-hosted-runner
92+
- name: Setup Python ${{ env.PYTHON_VERSION }} (Container)
93+
if: startsWith( runner.os, 'Linux' ) && env.IN_CONTAINER == 'true'
94+
shell: bash
95+
run: |
96+
sudo apt-get install -y --no-install-recommends python3-pip
97+
python3 -m pip install packaging
98+
99+
if python3 -c \
100+
'import sys; from packaging.version import parse; exit(0) if parse(".".join(map(str, sys.version_info[:2]))) < parse("${{ env.PYTHON_VERSION }}") else exit(1)'; \
101+
then
102+
103+
sudo add-apt-repository ppa:deadsnakes/ppa
104+
sudo apt update
105+
106+
sudo apt install -y --no-install-recommends \
107+
python${{ env.PYTHON_VERSION }} \
108+
python${{ env.PYTHON_VERSION }}-dev \
109+
python${{ env.PYTHON_VERSION }}-distutils
110+
111+
curl -sS https://bootstrap.pypa.io/get-pip.py | python${{ env.PYTHON_VERSION }}
112+
fi
113+
114+
ln -sf /usr/bin/python${{ env.PYTHON_VERSION }} /usr/local/bin/python
115+
116+
python --version
117+
pip --version
118+
119+
- name: Install Python dependencies
120+
run: |
121+
python -m pip install --upgrade pip setuptools wheel
122+
123+
- name: Setup AMBuild
124+
working-directory: ${{ env.CACHE_PATH }}
125+
run: |
126+
pip install ./ambuild
127+
128+
- name: Linux dependencies
129+
if: startsWith(runner.os, 'Linux')
130+
run: |
131+
sudo dpkg --add-architecture i386
132+
sudo apt-get update
133+
sudo apt-get install -y --no-install-recommends \
134+
gcc-multilib g++-multilib libstdc++6 lib32stdc++6 \
135+
libc6-dev libc6-dev-i386 linux-libc-dev \
136+
linux-libc-dev:i386 lib32z1-dev ${{ matrix.platform.cc }}
137+
138+
- name: Select clang compiler
139+
if: startsWith(runner.os, 'Linux')
140+
run: |
141+
echo "CC=${{ matrix.platform.cc }}" >> $GITHUB_ENV
142+
echo "CXX=${{ matrix.platform.cxx }}" >> $GITHUB_ENV
143+
${{ matrix.platform.cc }} --version
144+
${{ matrix.platform.cxx }} --version
145+
146+
- name: Build
147+
working-directory: sendvaredit
148+
shell: bash
149+
run: |
150+
mkdir build
151+
cd build
152+
python ../configure.py --enable-optimize --sdks=${{ join(fromJSON(env.SDKS)) }} \
153+
--mms-path="$GITHUB_WORKSPACE/${{ env.CACHE_PATH }}/metamod" \
154+
--hl2sdk-root="$GITHUB_WORKSPACE/${{ env.CACHE_PATH }}" \
155+
--sm-path="$GITHUB_WORKSPACE/${{ env.CACHE_PATH }}/sourcemod" \
156+
--hl2sdk-manifest-path="$GITHUB_WORKSPACE/${{ env.CACHE_PATH }}/sourcemod/hl2sdk-manifests" \
157+
--targets=x86
158+
ambuild
159+
160+
- name: Upload artifact
161+
uses: actions/upload-artifact@v4
162+
with:
163+
name: sendvaredit_${{ runner.os }}
164+
path: sendvaredit/build/package

.github/workflows/release.yml

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
name: Build Release
2+
3+
on:
4+
push:
5+
tags:
6+
- v**
7+
8+
jobs:
9+
build-extension:
10+
uses: ./.github/workflows/ci-ext.yml
11+
12+
release:
13+
permissions: write-all
14+
runs-on: ubuntu-latest
15+
needs: [build-extension]
16+
17+
steps:
18+
- run: sudo apt-get install -y tree
19+
20+
- name: Download Linux release
21+
uses: actions/download-artifact@v4
22+
with:
23+
name: sendvaredit_Linux
24+
path: sendvaredit_linux
25+
26+
- name: Download Windows release
27+
uses: actions/download-artifact@v4
28+
with:
29+
name: sendvaredit_Windows
30+
path: sendvaredit_windows
31+
32+
- name: Prepare archives
33+
run: |
34+
cd sendvaredit_linux
35+
tar -czf sendvaredit_linux.tar.gz *
36+
cd ../sendvaredit_windows
37+
zip -r sendvaredit_windows.zip .
38+
39+
- name: Create Release
40+
id: create_release
41+
uses: actions/create-release@v1
42+
env:
43+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
44+
with:
45+
tag_name: ${{ github.ref_name }}
46+
release_name: sendvaredit ${{ github.ref_name }}
47+
body: |
48+
${{ github.event.head_commit.message }}
49+
draft: false
50+
prerelease: false
51+
52+
- name: Upload Linux release
53+
uses: actions/upload-release-asset@v1
54+
env:
55+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
56+
with:
57+
upload_url: ${{ steps.create_release.outputs.upload_url }}
58+
asset_path: ./sendvaredit_linux/sendvaredit_linux.tar.gz
59+
asset_name: sendvaredit_${{ github.ref_name }}_linux.tar.gz
60+
asset_content_type: application/gzip
61+
62+
- name: Upload Windows release
63+
uses: actions/upload-release-asset@v1
64+
env:
65+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
66+
with:
67+
upload_url: ${{ steps.create_release.outputs.upload_url }}
68+
asset_path: ./sendvaredit_windows/sendvaredit_windows.zip
69+
asset_name: sendvaredit_${{ github.ref_name }}_windows.zip
70+
asset_content_type: application/zip

0 commit comments

Comments
 (0)