Skip to content

Commit fce10c0

Browse files
authored
Refactor projects and add rc-build workflow (#51)
* Refactor projects and add rc-build workflow * Fix build issues * Fix pr-build
1 parent a1d2aa0 commit fce10c0

25 files changed

+308
-434
lines changed

.github/workflows/pr-build.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
runs-on: ubuntu-latest
1717
env:
1818
DOTNET_VERSION: 9.0
19-
PROJECT: StarMapLoader/StarMapLoader.csproj
19+
PROJECT: StarMap.Launcher/StarMap.Launcher.csproj
2020
NUGET_SOURCE: "https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json"
2121

2222
steps:
@@ -33,8 +33,8 @@ jobs:
3333
dotnet nuget add source --username "${{ secrets.ORG_PACKAGE_USERNAME }}" --password "${{ secrets.ORG_PACKAGE_TOKEN }}" --store-password-in-clear-text --name github "${{ env.NUGET_SOURCE }}"
3434
dotnet restore ${{ env.PROJECT }}
3535
36-
# - name: Run tests
37-
# run: dotnet test --no-build --verbosity normal
38-
3936
- name: Build
4037
run: dotnet build ${{ env.PROJECT }} -c Release
38+
39+
# - name: Run tests
40+
# run: dotnet test --no-build --verbosity normal

.github/workflows/rc-build.yml

Lines changed: 198 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,198 @@
1+
name: Release new version
2+
3+
on:
4+
push:
5+
branches: [dev]
6+
7+
env:
8+
DOTNET_VERSION: 10.0
9+
STANDALONE_PROJECT: StarMap.Loader/StarMap.Loader.csproj
10+
LAUNCHER_PROJECT: StarMap.Launcher/StarMap.Launcher.csproj
11+
API_PROJECT: StarMap.API/StarMap.API.csproj
12+
STANDALONE_OUTPUT_PATH: ./publish/standalone
13+
LAUNCHER_OUTPUT_PATH: ./publish/launcher
14+
OUTPUT_PATH: ./publish
15+
NUGET_SOURCE: "https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json"
16+
EXCLUDE: "*.pdb *.xml"
17+
18+
jobs:
19+
build:
20+
runs-on: ubuntu-latest
21+
outputs:
22+
new_version: ${{ steps.version.outputs.new_version }}
23+
prev_version: ${{ steps.version.outputs.prev_version }}
24+
hash_version: ${{ steps.version.outputs.hash_version }}
25+
steps:
26+
- uses: actions/checkout@v4
27+
with:
28+
fetch-depth: 0
29+
fetch-tags: true
30+
31+
- uses: actions/setup-dotnet@v4
32+
with:
33+
dotnet-version: ${{ env.DOTNET_VERSION }}
34+
35+
- name: Determine version bump
36+
id: version
37+
run: |
38+
git fetch --tags --force || true
39+
40+
# Find latest semantic version
41+
current=$(git tag -l '[0-9]*.[0-9]*.[0-9]*' | sort -V | tail -n 1)
42+
if [ -z "$current" ]; then
43+
current="0.0.0"
44+
fi
45+
echo "Latest semantic tag: $current"
46+
47+
ver=${current#v}
48+
major=$(printf "%s" "$ver" | awk -F. '{print $1+0}')
49+
minor=$(printf "%s" "$ver" | awk -F. '{print $2+0}')
50+
patch=$(printf "%s" "$ver" | awk -F. '{print $3+0}')
51+
52+
patch=$((patch+1))
53+
new_version="${major}.${minor}.${patch}"
54+
55+
# Truly unique RC version
56+
hash_version="${new_version}-rc.${GITHUB_RUN_NUMBER}+${GITHUB_SHA::7}"
57+
58+
echo "Next version: $new_version"
59+
echo "RC version: $hash_version"
60+
61+
echo "prev_version=$current" >> $GITHUB_OUTPUT
62+
echo "new_version=$new_version" >> $GITHUB_OUTPUT
63+
echo "hash_version=$hash_version" >> $GITHUB_OUTPUT
64+
65+
- name: Setup NuGet source
66+
run: |
67+
dotnet nuget add source \
68+
--username ${{ secrets.ORG_PACKAGE_USERNAME }} \
69+
--password ${{ secrets.ORG_PACKAGE_TOKEN }} \
70+
--store-password-in-clear-text \
71+
--name github "${{ env.NUGET_SOURCE }}"
72+
73+
- name: Build launcher
74+
run: |
75+
dotnet publish ${{ env.LAUNCHER_PROJECT }} \
76+
-c Release \
77+
-o ${{ env.LAUNCHER_OUTPUT_PATH }} \
78+
-r win-x64 \
79+
--self-contained false \
80+
/p:PackageVersion=${{ steps.version.outputs.hash_version }} \
81+
/p:Version=${{ steps.version.outputs.new_version }} \
82+
/p:AssemblyVersion=${{ steps.version.outputs.new_version }} \
83+
/p:FileVersion=${{ steps.version.outputs.new_version }}
84+
85+
- name: Build standalone
86+
run: |
87+
dotnet publish ${{ env.STANDALONE_PROJECT }} \
88+
-c Release \
89+
-o ${{ env.STANDALONE_OUTPUT_PATH }} \
90+
-r win-x64 \
91+
--self-contained false \
92+
/p:PackageVersion=${{ steps.version.outputs.hash_version }} \
93+
/p:Version=${{ steps.version.outputs.new_version }} \
94+
/p:AssemblyVersion=${{ steps.version.outputs.new_version }} \
95+
/p:FileVersion=${{ steps.version.outputs.new_version }}
96+
97+
- name: Rename executables
98+
run: |
99+
mv ${{ env.LAUNCHER_OUTPUT_PATH }}/MyProgram.Launcher.exe ${{ env.LAUNCHER_OUTPUT_PATH }}/MyProgram.exe
100+
mv ${{ env.STANDALONE_OUTPUT_PATH }}/MyProgram.exe ${{ env.STANDALONE_OUTPUT_PATH }}/MyProgram.exe
101+
102+
- name: Write version file
103+
run: echo "${{ steps.version.outputs.hash_version }}" > version.txt
104+
105+
- name: Upload build artifacts
106+
uses: actions/upload-artifact@v4
107+
with:
108+
name: rc-build
109+
path: |
110+
${{ env.LAUNCHER_OUTPUT_PATH }}
111+
${{ env.STANDALONE_OUTPUT_PATH }}
112+
version.txt
113+
retention-days: 1
114+
115+
publish-RC-nuget:
116+
runs-on: ubuntu-latest
117+
needs: build
118+
steps:
119+
- uses: actions/checkout@v4
120+
with:
121+
fetch-depth: 0
122+
123+
- uses: actions/setup-dotnet@v4
124+
with:
125+
dotnet-version: ${{ env.DOTNET_VERSION }}
126+
127+
- name: Download build artifacts
128+
uses: actions/download-artifact@v4
129+
with:
130+
name: rc-build
131+
path: ./build_artifacts
132+
133+
- name: Pack and push RC NuGet package
134+
run: |
135+
dotnet restore ${{ env.API_PROJECT }}
136+
dotnet pack ${{ env.API_PROJECT }} \
137+
-c Release \
138+
-o ./nupkg \
139+
/p:PackageVersion=${{ needs.build.outputs.hash_version }} \
140+
/p:Version=${{ needs.build.outputs.new_version }} \
141+
/p:InformationalVersion=${{ needs.build.outputs.hash_version }}
142+
dotnet nuget add source --username "${{ github.actor }}" \
143+
--password "${{ secrets.GITHUB_TOKEN }}" \
144+
--store-password-in-clear-text \
145+
--name github "${{ env.NUGET_SOURCE }}"
146+
dotnet nuget push ./nupkg/*.nupkg \
147+
--source github \
148+
--api-key "${{ secrets.GITHUB_TOKEN }}" \
149+
--skip-duplicate
150+
151+
release-RC-zip:
152+
runs-on: ubuntu-latest
153+
needs: build
154+
steps:
155+
- uses: actions/checkout@v4
156+
with:
157+
fetch-depth: 0
158+
159+
- name: Download build artifacts
160+
uses: actions/download-artifact@v4
161+
with:
162+
name: rc-build
163+
path: ./build_artifacts
164+
165+
- name: Ensure zip is available
166+
run: |
167+
sudo apt-get update -y
168+
sudo apt-get install -y zip
169+
170+
- name: Package launcher ZIP
171+
run: |
172+
cd ./build_artifacts/${{ env.LAUNCHER_OUTPUT_PATH }}
173+
zip -r $GITHUB_WORKSPACE/StarMapLauncher-RC.zip . -x ${{ env.EXCLUDE }}
174+
cd -
175+
176+
- name: Package standalone ZIP
177+
run: |
178+
cd ./build_artifacts/${{ env.STANDALONE_OUTPUT_PATH }}
179+
zip -r $GITHUB_WORKSPACE/StarMapStandalone-RC.zip . -x ${{ env.EXCLUDE }}
180+
cd -
181+
182+
- name: Update RC GitHub release
183+
uses: softprops/action-gh-release@v1
184+
with:
185+
tag_name: rc
186+
name: Release Candidate
187+
prerelease: true
188+
files: |
189+
StarMapLauncher-RC.zip
190+
StarMapStandalone-RC.zip
191+
./build_artifacts/version.txt
192+
env:
193+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
194+
195+
- name: Update RC tag
196+
run: |
197+
git tag -f rc
198+
git push origin rc --force

.github/workflows/release.yml

Lines changed: 57 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@ jobs:
1414
packages: write
1515
env:
1616
DOTNET_VERSION: 9.0
17-
PROJECT: StarMapLoader/StarMapLoader.csproj
17+
STANDALONE_PROJECT: StarMap.Loader/StarMap.Loader.csproj
18+
LAUNCHER_PROJECT: StarMap.Launcher/StarMap.Launcher.csproj
19+
STANDALONE_OUTPUT_PATH: ./publish/standalone
20+
LAUNCHER_OUTPUT_PATH: ./publish/launcher
1821
OUTPUT_PATH: ./publish
1922
NUGET_SOURCE: "https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json"
2023
EXCLUDE: "*.pdb *.xml"
@@ -65,15 +68,6 @@ jobs:
6568
echo "type=$bump_type" >> $GITHUB_OUTPUT
6669
echo "new=$new_version" >> $GITHUB_OUTPUT
6770
68-
- name: Tag and push new version
69-
run: |
70-
git config user.name "github-actions"
71-
git config user.email "[email protected]"
72-
73-
NEW_VERSION="${{ steps.version.outputs.new }}"
74-
git tag "$NEW_VERSION"
75-
git push origin "$NEW_VERSION"
76-
7771
- name: Setup Github NuGet
7872
run: |
7973
dotnet nuget add source \
@@ -82,29 +76,27 @@ jobs:
8276
--store-password-in-clear-text \
8377
--name github "https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json"
8478
85-
- name: Build
86-
run: dotnet publish ${{ env.PROJECT }} -c Release -o ${{ env.OUTPUT_PATH }} -r win-x64 --self-contained false
79+
- name: Build launcher
80+
run: dotnet publish ${{ env.LAUNCHER_PROJECT }}
81+
-c Release -o ${{ env.LAUNCHER_OUTPUT_PATH }}
82+
-r win-x64
83+
--self-contained false
84+
/p:PackageVersion=${{ steps.version.outputs.new }} \
85+
/p:Version=${{ steps.version.outputs.new }} \
86+
/p:AssemblyVersion=${{ steps.version.outputs.new }} \
87+
/p:FileVersion=${{ steps.version.outputs.new }}
8788

88-
- name: Ensure zip is available
89-
run: |
90-
sudo apt-get update -y
91-
sudo apt-get install -y zip
89+
# - name: Run tests
90+
# run: dotnet test --no-build --verbosity normal
9291

93-
- name: Package ZIP
92+
- name: Tag and push new version
9493
run: |
95-
cd ${{ env.OUTPUT_PATH }}
96-
zip -r $GITHUB_WORKSPACE/StarMap-${{ steps.version.outputs.new }}.zip . -x ${{ env.EXCLUDE }}
97-
cd -
94+
git config user.name "github-actions"
95+
git config user.email "[email protected]"
9896
99-
- name: Create GitHub Release
100-
uses: softprops/action-gh-release@v2
101-
with:
102-
tag_name: ${{ steps.version.outputs.new }}
103-
name: Release ${{ steps.version.outputs.new }}
104-
body: |
105-
Automated release for version ${{ steps.version.outputs.new }}
106-
Triggered by PR #${{ github.event.pull_request.number }}
107-
files: StarMap-${{ steps.version.outputs.new }}.zip
97+
NEW_VERSION="${{ steps.version.outputs.new }}"
98+
git tag "$NEW_VERSION"
99+
git push origin "$NEW_VERSION"
108100
109101
- name: Check whether StarMap.API changed since previous tag
110102
id: api_check
@@ -152,6 +144,42 @@ jobs:
152144
--api-key "${{ secrets.NUGET_API_KEY }}" \
153145
--skip-duplicate
154146
147+
- name: Build standalone
148+
run: dotnet publish ${{ env.STANDALONE_PROJECT }}
149+
-c Release -o ${{ env.STANDALONE_OUTPUT_PATH }}
150+
-r win-x64
151+
--self-contained false
152+
/p:PackageVersion=${{ steps.version.outputs.new }} \
153+
/p:Version=${{ steps.version.outputs.new }} \
154+
/p:AssemblyVersion=${{ steps.version.outputs.new }} \
155+
/p:FileVersion=${{ steps.version.outputs.new }}
156+
157+
- name: Rename executables
158+
run: |
159+
ren publish\launcher\MyProgram.Launcher.exe MyProgram.exe
160+
ren publish\launcher\MyProgram.Launcher.exe MyProgram.exe
161+
162+
- name: Ensure zip is available
163+
run: |
164+
sudo apt-get update -y
165+
sudo apt-get install -y zip
166+
167+
- name: Package launcher ZIP
168+
run: |
169+
cd ${{ env.LAUNCHER_OUTPUT_PATH }}
170+
zip -r $GITHUB_WORKSPACE/StarMapLauncher-${{ steps.version.outputs.new }}.zip . -x ${{ env.EXCLUDE }}
171+
cd -
172+
173+
- name: Create GitHub Release
174+
uses: softprops/action-gh-release@v2
175+
with:
176+
tag_name: ${{ steps.version.outputs.new }}
177+
name: Release ${{ steps.version.outputs.new }}
178+
body: |
179+
Automated release for version ${{ steps.version.outputs.new }}
180+
Triggered by PR #${{ github.event.pull_request.number }}
181+
files: StarMap-${{ steps.version.outputs.new }}.zip
182+
155183
- name: Upload publish folder for Windows installer
156184
uses: actions/upload-artifact@v4
157185
with:

DummyProgram/DummyProgram.csproj

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

DummyProgram/Mod.cs

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

0 commit comments

Comments
 (0)