Skip to content

Commit 2a5f942

Browse files
committed
Build in GitHub Actions
1 parent 9452a0c commit 2a5f942

File tree

3 files changed

+210
-0
lines changed

3 files changed

+210
-0
lines changed

.github/workflows/ci.yml

Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
name: CI
2+
on:
3+
workflow_call:
4+
permissions:
5+
contents: read
6+
jobs:
7+
build-windows:
8+
name: Build on Windows
9+
runs-on: windows-latest
10+
steps:
11+
- name: Check Out Repository
12+
uses: actions/checkout@v4
13+
- name: Download External Dependencies
14+
run: |
15+
set -x
16+
17+
curl -fsSL -o 'C:\openssl.tar.gz' 'https://www.openssl.org/source/old/1.1.1/openssl-1.1.1w.tar.gz'
18+
sha256sum -c <<<'cf3098950cb4d853ad95c0841f1f9c6d3dc102dccfcacd521d93925208b76ac8 *C:\openssl.tar.gz'
19+
(cd 'C:\'; tar --force-local -xf 'C:\openssl.tar.gz')
20+
21+
curl -fsSL -o 'C:\p4api_win32.zip' 'https://ftp.perforce.com/perforce/r24.1/bin.ntx86/p4api_vs2022_static_openssl1.1.1.zip'
22+
mkdir -p 'C:\p4api\win32'
23+
(cd 'C:\p4api\win32'; unzip -q 'C:\p4api_win32.zip')
24+
25+
mkdir -p 'PerforceBinaries\Win_x64'
26+
curl -fsSL -o 'PerforceBinaries\Win_x64\p4d.exe' 'https://ftp.perforce.com/perforce/r24.1/bin.ntx64/p4d.exe'
27+
curl -fsSL -o 'PerforceBinaries\Win_x64\p4.exe' 'https://ftp.perforce.com/perforce/r24.1/bin.ntx64/p4.exe'
28+
shell: bash
29+
- name: Set Up Developer Command Prompt
30+
uses: ilammy/msvc-dev-cmd@v1
31+
with:
32+
arch: x86
33+
- name: Install the Netwide Assembler
34+
uses: ilammy/setup-nasm@v1
35+
- name: Build OpenSSL
36+
working-directory: C:\openssl-1.1.1w
37+
run: |
38+
perl Configure no-shared no-tests VC-WIN32 -DWINVER=0x0601 -D_WIN32_WINNT=0x0601
39+
nmake
40+
nmake install_sw
41+
- name: Build
42+
run: |
43+
$env:INCLUDE += ";$(Resolve-Path 'C:\p4api\win32\p4api-*\include\p4\')"
44+
$env:LIB += ";$(Resolve-Path 'C:\p4api\win32\p4api-*\lib');${env:ProgramFiles(x86)}\OpenSSL\lib"
45+
46+
msbuild VersionControl.sln /t:Clean /t:P4Plugin /t:TestServer /p:Configuration=Release /p:Platform=Win32 /p:UseEnv=true
47+
- name: Upload Artifacts
48+
uses: actions/upload-artifact@v4
49+
with:
50+
name: unity-p4-plugin-ntx86
51+
path: Build/Win32/PerforcePlugin.exe
52+
- name: Test
53+
run: |
54+
perl build.pl -test
55+
build-linux:
56+
name: Build on Linux
57+
runs-on: ubuntu-20.04
58+
steps:
59+
- name: Check Out Repository
60+
uses: actions/checkout@v4
61+
- name: Install Dependencies
62+
run: |
63+
sudo apt-get update
64+
sudo apt-get install -y libgtk-3-dev libssl-dev
65+
- name: Download External Dependencies
66+
run: |
67+
set -x
68+
69+
curl -fsSL -o /tmp/p4api_linux64.tgz 'https://ftp.perforce.com/perforce/r24.1/bin.linux26x86_64/p4api-glibc2.12-openssl1.1.1.tgz'
70+
tar -C /tmp -xf /tmp/p4api_linux64.tgz
71+
72+
mkdir -p PerforceBinaries/linux64
73+
curl -fsSL -o 'PerforceBinaries/linux64/p4d' 'https://ftp.perforce.com/perforce/r24.1/bin.linux26x86_64/p4d'
74+
curl -fsSL -o 'PerforceBinaries/linux64/p4' 'https://ftp.perforce.com/perforce/r24.1/bin.linux26x86_64/p4'
75+
chmod +x PerforceBinaries/linux64/p4d PerforceBinaries/linux64/p4
76+
- name: Build
77+
run: |
78+
include_dir=(/tmp/p4api-*/include/p4)
79+
lib_dir=(/tmp/p4api-*/lib)
80+
81+
export CFLAGS="-O3 -fPIC -fexceptions -fvisibility=hidden -DLINUX -I$include_dir"
82+
export CXXFLAGS="$CFLAGS"
83+
export LDLIBS="-L$lib_dir"
84+
85+
make -f Makefile.gnu PLATFORM=linux64
86+
- name: Upload Artifacts
87+
uses: actions/upload-artifact@v4
88+
with:
89+
name: unity-p4-plugin-linux26x86_64-glibc2.31
90+
path: Build/linux64/PerforcePlugin
91+
- name: Test
92+
run: |
93+
perl build.pl -test
94+
build-macos:
95+
name: Build on macOS
96+
runs-on: macos-latest
97+
steps:
98+
- name: Check Out Repository
99+
uses: actions/checkout@v4
100+
- name: Download External Dependencies
101+
run: |
102+
set -x
103+
104+
curl -sSL -o /tmp/openssl.tar.gz 'https://www.openssl.org/source/old/1.1.1/openssl-1.1.1w.tar.gz'
105+
shasum -a 256 -c <<<'cf3098950cb4d853ad95c0841f1f9c6d3dc102dccfcacd521d93925208b76ac8 */tmp/openssl.tar.gz'
106+
tar -C /tmp -xf /tmp/openssl.tar.gz
107+
108+
curl -sSL -o /tmp/p4api_macos64.tgz 'https://ftp.perforce.com/perforce/r24.1/bin.macosx105x86_64/p4api-openssl1.1.1.tgz'
109+
tar -C /tmp -xf /tmp/p4api_macos64.tgz
110+
111+
mkdir -p PerforceBinaries/OSX
112+
curl -sSL -o 'PerforceBinaries/OSX/p4d' 'https://ftp.perforce.com/perforce/r24.1/bin.macosx12arm64/p4d'
113+
curl -sSL -o 'PerforceBinaries/OSX/p4' 'https://ftp.perforce.com/perforce/r24.1/bin.macosx12arm64/p4'
114+
chmod +x PerforceBinaries/OSX/p4d PerforceBinaries/OSX/p4
115+
- name: Build OpenSSL
116+
working-directory: /tmp/openssl-1.1.1w
117+
run: |
118+
perl Configure no-shared no-tests darwin64-x86_64-cc -mmacosx-version-min=10.11 --prefix=/usr/local/ssl/[email protected]_64
119+
make depend
120+
sudo make install_sw
121+
- name: Build
122+
run: |
123+
include_dir=(/tmp/p4api-*/include/p4)
124+
lib_dir=(/tmp/p4api-*/lib)
125+
126+
export CFLAGS="-I$include_dir"
127+
export CXXFLAGS="$CFLAGS"
128+
export LDLIBS="-L$lib_dir -L/usr/local/ssl/[email protected]_64/lib"
129+
130+
make -f Makefile.osx
131+
- name: Upload Artifacts
132+
uses: actions/upload-artifact@v4
133+
with:
134+
name: unity-p4-plugin-macosx1011x86_64
135+
path: Build/OSXx64/PerforcePlugin
136+
- name: Test
137+
run: |
138+
perl build.pl -test

.github/workflows/pipeline.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: Pipeline
2+
on:
3+
push:
4+
permissions:
5+
contents: write
6+
jobs:
7+
ci:
8+
name: CI
9+
uses: ./.github/workflows/ci.yml
10+
secrets: inherit
11+
release:
12+
name: Release
13+
needs: ci
14+
if: startsWith(github.ref, 'refs/tags/')
15+
uses: ./.github/workflows/release.yml
16+
with:
17+
version: ${{ github.ref_name }}
18+
secrets: inherit

.github/workflows/release.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: Release
2+
on:
3+
workflow_call:
4+
inputs:
5+
version:
6+
required: true
7+
type: string
8+
permissions:
9+
contents: write
10+
jobs:
11+
release:
12+
name: Release
13+
runs-on: ubuntu-20.04
14+
steps:
15+
- name: Check Out Repository
16+
uses: actions/checkout@v4
17+
- name: Download Artifacts
18+
uses: actions/download-artifact@v4
19+
with:
20+
path: ${{ runner.temp }}
21+
- name: Create Release Directories
22+
working-directory: ${{ runner.temp }}
23+
run: |
24+
mkdir -p stage/{bin.ntx86,bin.linux26x86_64,bin.macosx1011x86_64}
25+
- name: Stage Windows Release Files
26+
working-directory: ${{ runner.temp }}/stage/bin.ntx86
27+
env:
28+
PLUGIN_VERSION: ${{ inputs.version }}
29+
run: |
30+
mkdir "unity-p4-plugin-${PLUGIN_VERSION}"
31+
cp -rv "$RUNNER_TEMP/unity-p4-plugin-ntx86/"* "unity-p4-plugin-${PLUGIN_VERSION}"
32+
zip -r unity-p4-plugin.ntx86.zip "unity-p4-plugin-${PLUGIN_VERSION}"
33+
- name: Stage Linux Release Files
34+
working-directory: ${{ runner.temp }}/stage/bin.linux26x86_64
35+
env:
36+
PLUGIN_VERSION: ${{ inputs.version }}
37+
run: |
38+
mkdir "unity-p4-plugin-${PLUGIN_VERSION}"
39+
cp -rv "$RUNNER_TEMP/unity-p4-plugin-linux26x86_64-glibc2.31/"* "unity-p4-plugin-${PLUGIN_VERSION}"
40+
tar -czf unity-p4-plugin.linux26x86_64-glibc2.31.tgz "unity-p4-plugin-${PLUGIN_VERSION}"
41+
- name: Stage macOS Release Files
42+
working-directory: ${{ runner.temp }}/stage/bin.macosx1011x86_64
43+
env:
44+
PLUGIN_VERSION: ${{ inputs.version }}
45+
run: |
46+
mkdir "unity-p4-plugin-${PLUGIN_VERSION}"
47+
cp -rv "$RUNNER_TEMP/unity-p4-plugin-macosx1011x86_64/"* "unity-p4-plugin-${PLUGIN_VERSION}"
48+
tar -czf unity-p4-plugin.macosx1011x86_64.tgz "unity-p4-plugin-${PLUGIN_VERSION}"
49+
- name: Create Release
50+
env:
51+
GH_TOKEN: ${{ github.token }}
52+
PLUGIN_VERSION: ${{ inputs.version }}
53+
run: |
54+
gh release create -R "$GITHUB_REPOSITORY" --generate-notes "$PLUGIN_VERSION" "$RUNNER_TEMP/stage/"*/*.{zip,tgz}

0 commit comments

Comments
 (0)