-
-
Notifications
You must be signed in to change notification settings - Fork 2
106 lines (92 loc) · 2.92 KB
/
pre-release.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
name: "pre-release"
on:
push:
branches:
- "main"
tags-ignore:
- "*"
jobs:
pre-release:
name: "Pre Release"
continue-on-error: true
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
name: battleship-linux
- os: windows-latest
name: battleship-windows.exe
runs-on: ${{ matrix.os }}
steps:
- name: "Checkout source code"
uses: actions/checkout@master
with:
fetch-depth: 1
- name: Get short SHA (Windows)
if: matrix.os == 'windows-latest'
run: echo "SHORT_SHA=$("${{ github.sha }}".SubString(0, 8))" >> $env:GITHUB_ENV
- name: Get short SHA (Linux)
if: matrix.os != 'windows-latest'
run: echo "SHORT_SHA=`echo ${{github.sha}} | cut -c1-8`" >> $GITHUB_ENV
- name: "Build Project (Windows)"
if: matrix.os == 'windows-latest'
run: |
cmake -DPROGRAM_VERSION="${{env.SHORT_SHA}}" -G Ninja -DCMAKE_BUILD_TYPE=Release -S . -B build
cmake --build build -- -j 2
mv build\battleship.exe ${{ matrix.name }}
- name: "Build Project (Linux/macOS)"
if: matrix.os != 'windows-latest'
run: |
make PROGRAM_VERSION=${SHORT_SHA} release
mv build/battleship ${{ matrix.name }}
- name: "Calculate SHA-256 sum"
id: hash
run:
openssl dgst -sha256 -r ${{ matrix.name }} | awk '{print $1}' > "${{ matrix.name }}.sha256"
- name: "Release | Upload artifacts"
uses: actions/upload-artifact@v3
with:
name: battleship
path: |
${{ matrix.name }}.sha256
${{ matrix.name }}
build-server:
name: Build Server (Linux)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
- name: "Build Server"
run: |
make server
mv build/server battleship-server-linux
- name: "Calculate SHA-256 sum"
id: hash
run:
openssl dgst -sha256 -r battleship-server-linux | awk '{print $1}' > "battleship-server-linux.sha256"
- name: "Release | Upload artifacts"
uses: actions/upload-artifact@v3
with:
name: battleship
path: |
battleship-server-linux.sha256
battleship-server-linux
upload_artifacts:
name: Add Build Artifacts to Release
needs:
- pre-release
- build-server
runs-on: ubuntu-latest
steps:
- name: Setup | Artifacts
uses: actions/download-artifact@v3
- uses: "marvinpinto/action-automatic-releases@latest"
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
automatic_release_tag: "latest"
prerelease: true
title: "Development Build"
files: battleship/battleship*