Skip to content

Commit e5a1afa

Browse files
authored
Merge pull request #12 from cortex-command-community/master-release-workflow
add a new workflow to publish releases
2 parents 1e29c7b + 750a69a commit e5a1afa

File tree

6 files changed

+194
-31
lines changed

6 files changed

+194
-31
lines changed
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: 'Bundle Release Assets'
2+
description: 'Downloads build assets and packages them into a zip file along with game data and libraries'
3+
runs:
4+
using: "composite"
5+
steps:
6+
- run: mkdir release
7+
shell: bash
8+
9+
- name: Download build artefacts
10+
uses: actions/download-artifact@v3
11+
with:
12+
path: release
13+
14+
- run: ls -R release
15+
shell: bash
16+
17+
- name: Compress Windows Release
18+
shell: bash
19+
run: |
20+
zip -j CortexCommand.windows.zip \
21+
"release/Cortex Command.exe" \
22+
external/lib/win/{fmod,SDL2}.dll
23+
24+
- name: Compress Linux Release
25+
shell: bash
26+
run: |
27+
zip -j CortexCommand.linux.zip \
28+
"release/CortexCommand (Linux)/CortexCommand.AppImage" \
29+
external/lib/linux/x86_64/libfmod.so*
30+
31+
- name: Compress OSX Release
32+
shell: bash
33+
run: |
34+
zip -j CortexCommand.macos.zip \
35+
"release/CortexCommand (macOS)/CortexCommand" \
36+
external/lib/macos/libfmod.dylib
37+
38+
- name: Package Data files
39+
shell: bash
40+
run: |
41+
zip -r -u CortexCommand.windows.zip Data
42+
zip -r -u CortexCommand.linux.zip Data
43+
zip -r -u CortexCommand.macos.zip Data
44+
45+
46+
47+
48+
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: 'Set Version'
2+
description: 'Updates all references to the current game version'
3+
inputs:
4+
new_release_version:
5+
description: 'The new version string'
6+
required: true
7+
runs:
8+
using: "composite"
9+
steps:
10+
- name: Set Constants.h GameVersion
11+
run: sed -i -E '/c_VersionString = /s/"[^"]*"/"${{inputs.new_release_version}}"/' Source/System/GameVersion.h
12+
shell: bash
13+
14+
- uses: actions/setup-python@v3
15+
16+
- name: Rewrite meson version
17+
run: |
18+
pip install meson
19+
meson rewrite kwargs set project // version ${{ inputs.new_release_version }}
20+
shell: bash

.github/workflows/master_build.yaml

Lines changed: 0 additions & 27 deletions
This file was deleted.

.github/workflows/meson.yml

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ on:
2626
- "release"
2727
- "minimal"
2828
- "full"
29+
new_release_version:
30+
type: string
31+
required: false
2932

3033
# Triggers the workflow when called by a top-level workflow
3134
workflow_call:
@@ -42,6 +45,9 @@ on:
4245
type: string
4346
required: false
4447
default: "release"
48+
new_release_version:
49+
type: string
50+
required: false
4551

4652
jobs:
4753
build-linux:
@@ -59,6 +65,13 @@ jobs:
5965
sudo apt-get install --no-install-recommends wget liballegro4-dev libloadpng4-dev libflac++-dev luajit-5.1-dev liblua5.2-dev libminizip-dev liblz4-dev libpng++-dev libx11-dev libboost-dev libtbb-dev libsdl2-dev libsdl2-image-dev libopengl-dev libfuse2 ninja-build
6066
sudo pip install meson
6167
68+
- name: Set Version
69+
if: ${{inputs.new_release_version}}
70+
uses: ./.github/actions/set_version
71+
with:
72+
new_release_version: ${{inputs.new_release_version}}
73+
github_token: ${{ secrets.GITHUB_TOKEN }}
74+
6275
- name: Setup Meson
6376
env:
6477
CC: "gcc"
@@ -114,7 +127,7 @@ jobs:
114127
build-macos:
115128
runs-on: macos-11
116129
name: MacOS Build
117-
130+
118131
env:
119132
GCC_VERSION: "13"
120133
MACOSX_DEPLOYMENT_TARGET: 10.15
@@ -124,8 +137,15 @@ jobs:
124137

125138
- name: "Install Dependencies"
126139
uses: melusina-org/setup-macports@v1
127-
with:
128-
parameters: ".github/parameters/macports.yml"
140+
with:
141+
parameters: ".github/parameters/macports.yml"
142+
143+
- name: Set Version
144+
if: ${{inputs.new_release_version}}
145+
uses: ./.github/actions/set_version
146+
with:
147+
new_release_version: ${{inputs.new_release_version}}
148+
github_token: ${{ secrets.GITHUB_TOKEN }}
129149

130150
- name: Setup Meson
131151
env:

.github/workflows/msbuild.yml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ on:
1919
- "Debug Release"
2020
- "Debug Minimal"
2121
- "Debug Full"
22+
new_release_version:
23+
type: string
24+
required: false
2225

2326
# Triggers the workflow when called by a top-level workflow
2427
workflow_call:
@@ -31,7 +34,9 @@ on:
3134
type: string
3235
required: false
3336
default: "Final"
34-
37+
new_release_version:
38+
type: string
39+
required: false
3540
env:
3641
# Path to the solution file relative to the root of the project.
3742
SOLUTION_FILE_PATH: RTEA.sln
@@ -54,6 +59,13 @@ jobs:
5459
- name: Add MSBuild to PATH
5560
uses: microsoft/setup-msbuild@v1
5661

62+
- name: Set Version
63+
if: ${{inputs.new_release_version}}
64+
uses: ./.github/actions/set_version
65+
with:
66+
new_release_version: ${{inputs.new_release_version}}
67+
github_token: ${{ secrets.GITHUB_TOKEN }}
68+
5769
- name: Build
5870
working-directory: ${{env.GITHUB_WORKSPACE}}
5971
# Add additional options to the MSBuild command line here (like platform or verbosity level).

.github/workflows/release.yaml

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
name: Build and Release
2+
# Controls when the action will run.
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
new_release_version:
7+
description: "New version number to release"
8+
type: string
9+
required: true
10+
11+
concurrency:
12+
group: release-${{ github.ref_name }}
13+
14+
env:
15+
LATEST_TAG: latest
16+
17+
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
18+
jobs:
19+
build-meson-releases:
20+
name: Linux & macOS Release Builds
21+
22+
uses: ./.github/workflows/meson.yml
23+
with:
24+
upload_artefacts: true
25+
new_release_version: ${{ github.event.inputs.new_release_version }}
26+
27+
build-msbuild-releases:
28+
name: Windows Release Build
29+
30+
uses: ./.github/workflows/msbuild.yml
31+
with:
32+
upload_artefacts: true
33+
new_release_version: ${{ github.event.inputs.new_release_version }}
34+
35+
release:
36+
name: Publish Release
37+
runs-on: ubuntu-latest
38+
39+
needs: [build-msbuild-releases, build-meson-releases]
40+
41+
steps:
42+
- name: Checkout code
43+
uses: actions/checkout@v3
44+
45+
- name: fetch tags
46+
run: git fetch --tags origin
47+
48+
- name: Set Version
49+
if: ${{ github.event.inputs.new_release_version}}
50+
uses: ./.github/actions/set_version
51+
with:
52+
new_release_version: ${{ github.event.inputs.new_release_version}}
53+
54+
- name: Bundle release assets
55+
uses: ./.github/actions/bundle_release
56+
57+
- name: Create a new Release
58+
run: |
59+
gh release create v${{ github.event.inputs.new_release_version }} \
60+
--title "Release ${{ github.event.inputs.new_release_version }}" \
61+
--generate-notes \
62+
--draft \
63+
--target ${{ github.ref_name }} \
64+
${{format('--notes-start-tag {0}', env.LATEST_TAG) || ''}} \
65+
'CortexCommand.windows.zip#Cortex Command [v${{ github.event.inputs.new_release_version }}] (Windows Release)' \
66+
'CortexCommand.linux.zip#Cortex Command [v${{ github.event.inputs.new_release_version }}] (Linux Release)' \
67+
'CortexCommand.macos.zip#Cortex Command [v${{ github.event.inputs.new_release_version }}] (macOS Release)'
68+
env:
69+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
70+
71+
- name: Commit and push Version Changes and Update latest tag
72+
shell: bash
73+
run: |
74+
git config --global user.email "[email protected]"
75+
git config --global user.name "GitHub Action"
76+
git add Source/System/GameVersion.h meson.build
77+
git commit -m "Release v${{ inputs.new_release_version }}" || echo "No changes to commit"
78+
git push
79+
80+
RELEASE_COMMIT=$(git rev-parse HEAD)
81+
curl -X PATCH \
82+
-H "Authorization: Bearer ${{ secrets.WORKFLOW_TOKEN }}" \
83+
-H "Accept: application/vnd.github.v3+json" \
84+
https://api.github.com/repos/${{ github.repository }}/git/refs/tags/${{ env.LATEST_TAG }} \
85+
-d '{
86+
"sha": "'"$RELEASE_COMMIT"'",
87+
"ref": "${{ github.ref }}"
88+
}'
89+
env:
90+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN}}

0 commit comments

Comments
 (0)