Skip to content

Commit 32b2c88

Browse files
author
hiran
committed
calculate version number early in the build
1 parent e45bc49 commit 32b2c88

File tree

2 files changed

+87
-22
lines changed

2 files changed

+87
-22
lines changed

.github/workflows/build-all.yml

Lines changed: 86 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
name: build-all
32

43
on:
@@ -22,11 +21,33 @@ jobs:
2221
fetch-depth: 0
2322
submodules: true
2423

24+
- name: Calculate version number and set OOLITE_VERSION
25+
id: version
26+
run: |
27+
set -x
28+
cd oolite
29+
# Build version string,
30+
# taking into account that we may have just two digits
31+
VERSION=$(cat src/Cocoa/oolite-version.xcconfig | cut -d '=' -f 2)
32+
VER_MAJ=$(echo ${VERSION} | cut -d. -f1)
33+
VER_MIN=$(echo ${VERSION} | cut -d. -f2)
34+
VER_REV=$(echo ${VERSION} | cut -d. -f3)
35+
if [ "" == "${VER_REV}" ]
36+
then
37+
VER_REV="0"
38+
fi
39+
VER_DATE=$(date +%y%m%d)
40+
VER_GITREV=$(git rev-list --count HEAD)
41+
VER_GITHASH=$(git rev-parse --short=7 HEAD)
42+
VER="${VER_MAJ}.${VER_MIN}.${VER_REV}.${VER_GITREV}-${VER_DATE}-${VER_GITHASH}"
43+
echo "OOLITE_VERSION=${VER}" >> "$GITHUB_OUTPUT"
44+
echo "OOLITE_VERSION=${VER}" >> Doc/OOLITE_VERSION.txt
45+
2546
- name: generate PDFs
2647
run: |
2748
find oolite/Doc -name "*.odt" -exec soffice --headless --convert-to pdf:"writer_pdf_Export" --outdir oolite/Doc {} \;
28-
zip oolite-doc.zip oolite/Doc/*.pdf
29-
49+
zip oolite-doc.zip oolite/Doc/*.pdf oolite/Doc/OOLITE_VERSION.txt
50+
3051
- name: Archive generated documentation
3152
uses: actions/upload-artifact@v3
3253
with:
@@ -40,7 +61,7 @@ jobs:
4061
needs: [common-steps]
4162
steps:
4263
## This is for debugging only and helps developing the workflow.
43-
#- name: Environment Variables
64+
# - name: Environment Variables
4465
# run: |
4566
# printenv | sort
4667

@@ -61,7 +82,7 @@ jobs:
6182
with:
6283
name: oolite-doc
6384
path: artifacts
64-
85+
6586
- name: Extract PDFs
6687
run: |
6788
unzip -u artifacts/oolite-doc.zip
@@ -70,15 +91,15 @@ jobs:
7091
- name: show filesystem before build
7192
run: |
7293
find . -not -path "./oolite/deps/Windows-deps/*" -not -path "./oolite/Mac-specific/*" -not -path "./oolite/.git/*"
73-
94+
7495
- name: compiling up to installer script (.run file)
7596
run: |
7697
cd oolite
7798
source /usr/share/GNUstep/Makefiles/GNUstep.sh
7899
make -f Makefile pkg-posix-nightly HOST_ARCH=$(uname -m)
79-
100+
80101
## This is for debugging only and helps developing the workflow.
81-
#- name: show filesystem after build
102+
# - name: show filesystem after build
82103
# run: |
83104
# find . -not -path "./oolite/Mac-specific/*" -not -path "./oolite/deps/Windows-deps/*" -not -path "./oolite/tests/*" -not -path "./oolite/.git/*" -not -path "./oolite/deps/mozilla/*"
84105

@@ -91,34 +112,34 @@ jobs:
91112
run: |
92113
NAME=$(basename oolite-nightly/oolite-*.run .run)
93114
tar cvfz ${NAME}.tgz -C oolite-nightly .
94-
115+
95116
# This is for debugging only and helps developing the workflow.
96117
- name: show filesystem after installer
97118
run: |
98119
find . -not -path "./oolite/Mac-specific/*" -not -path "./oolite/deps/*" -not -path "./oolite/tests/*" -not -path "./oolite/.git/*"
99-
120+
100121
- name: Archive build tar ball
101122
uses: actions/upload-artifact@v3
102123
with:
103124
name: oolite-linux-nightly
104125
path: |
105126
oolite-*.tgz
106127
retention-days: 5
107-
128+
108129

109130
build-windows:
110131
runs-on: windows-latest
111132
needs: [common-steps]
112133
steps:
113134
## This is for debugging only and helps developing the workflow.
114-
#- name: Environment Variables
135+
# - name: Environment Variables
115136
# run: |
116137
# Get-ChildItem Env: | Sort Name
117138

118139
- name: Checkout DevelopmentEnvironment
119140
uses: actions/checkout@v3
120141
with:
121-
repository: OoliteProject/oolite-windows-build-env
142+
repository: OoliteProject/oolite-windows-build-env
122143
path: DevelopmentEnvironment
123144

124145
- name: Checkout Oolite
@@ -133,7 +154,7 @@ jobs:
133154
with:
134155
name: oolite-doc
135156
path: artifacts
136-
157+
137158
- name: Extract PDFs
138159
run: |
139160
unzip -u artifacts/oolite-doc.zip
@@ -147,7 +168,7 @@ jobs:
147168
- name: Compile
148169
shell: cmd
149170
run: D:\a\oolite\oolite\DevelopmentEnvironment\gcc\Msys_x2\1.0\msys.cmd
150-
171+
151172
# check http://aegidian.org/bb/viewtopic.php?p=281821#p281821
152173
# this is for debug only; it creates huge logs and takes a long time to execute, yet you never know when you need it
153174
- name: check filesystem
@@ -164,6 +185,7 @@ jobs:
164185

165186
build-doxygen:
166187
runs-on: ubuntu-latest
188+
needs: [common-steps]
167189
steps:
168190
- name: Checkout Oolite
169191
uses: actions/checkout@v3
@@ -172,24 +194,45 @@ jobs:
172194
fetch-depth: 0
173195
submodules: true
174196

197+
- name: Download artifacts
198+
uses: actions/download-artifact@v3
199+
with:
200+
name: oolite-doc
201+
path: artifacts
202+
203+
- name: Extract artifacts
204+
run: |
205+
unzip -u artifacts/oolite-doc.zip
206+
207+
- name: set version
208+
id: version
209+
run: |
210+
OOLITE_VERSION=$(cat oolite/Doc/OOLITE_VERSION.txt | cut -d= -f2)
211+
echo "OOLITE_VERSION=${OOLITE_VERSION}" >> "$GITHUB_OUTPUT"
212+
sed -i -e "/PROJECT_NUMBER\s*=/ s/=.*/=${OOLITE_VERSION}/" oolite/Doxyfile
213+
cat oolite/Doxyfile
214+
175215
- name: Run doxygen
176216
uses: mattnotmitt/[email protected]
177217
with:
178218
working-directory: oolite
219+
# OOLITE_VERSION: ${{ steps.version.outputs.OOLITE_VERSION }}
179220

180221
## This is for debugging only and helps developing the workflow.
181-
#- name: Environment Variables 1
222+
# - name: Environment Variables 1
182223
# run: |
183224
# printenv | sort
184225
# find . -not -path "./oolite/deps/*" -not -path "./oolite/Mac-specific/*" -not -path "./oolite/.git/*"
185226

186227
- name: create tar ball
187228
run: |
188-
tar cvfz oolite-apidoc.tgz -C oolite doxygen
229+
tar cvfz oolite-apidoc-${{ steps.version.outputs.OOLITE_VERSION }}.tgz -C oolite doxygen
230+
189231
# This is for debugging only and helps developing the workflow.
190232
- name: Environment Variables 2
191233
run: |
192234
find . -not -path "./oolite/deps/*" -not -path "./oolite/Mac-specific/*" -not -path "./oolite/.git/*"
235+
193236
- name: Archive build tar ball
194237
uses: actions/upload-artifact@v3
195238
with:
@@ -203,7 +246,7 @@ jobs:
203246
runs-on: ubuntu-latest
204247
steps:
205248
## This is for debugging only and helps developing the workflow.
206-
#- name: Environment Variables
249+
# - name: Environment Variables
207250
# run: |
208251
# printenv | sort
209252

@@ -212,11 +255,32 @@ jobs:
212255
with:
213256
path: artifacts
214257

258+
- name: Extract artifacts
259+
run: |
260+
unzip -u artifacts/oolite-doc.zip
261+
262+
- name: set version
263+
id: version
264+
run: |
265+
OOLITE_VERSION=$(cat oolite/Doc/OOLITE_VERSION.txt | cut -d= -f2)
266+
215267
# This is for debugging only and helps developing the workflow.
216268
- name: show filesystem after download
217269
run: |
218270
find .
219-
271+
272+
- name: Remove old prereleases
273+
if: github.ref != 'refs/heads/master'
274+
uses: s00d/[email protected]
275+
with:
276+
#repo: <owner>/<repoName> # defaults to current repo
277+
keep_latest: 7
278+
#delete_tag_pattern: v\d+\.\d+\.\d+-.*
279+
delete_type: 'prerelease'
280+
#delete_branch: '${{ github.ref_name }}'
281+
env:
282+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
283+
220284
# For changes on master branch, create a new release.
221285
# It should move the 'latest' tag automatically.
222286
- name: Create Release
@@ -225,9 +289,10 @@ jobs:
225289
uses: "marvinpinto/action-automatic-releases@latest"
226290
with:
227291
repo_token: "${{ secrets.GITHUB_TOKEN }}"
228-
automatic_release_tag: "latest"
292+
# automatic_release_tag: "latest"
293+
automatic_release_tag: "${{ steps.version.outputs.OOLITE_VERSION }}"
229294
prerelease: true
230-
title: "Oolite Nightly"
295+
title: "Oolite ${{ steps.version.outputs.OOLITE_VERSION }}"
231296
files: |
232297
artifacts/oolite-documentation-nightly/oolite-*.tgz
233298
artifacts/oolite-linux-nightly/oolite-*.tgz

Doxyfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ PROJECT_NAME = "Oolite"
3838
# could be handy for archiving the generated documentation or if some version
3939
# control system is used.
4040

41-
PROJECT_NUMBER =
41+
PROJECT_NUMBER = $(OOLITE_VERSION)
4242

4343
# Using the PROJECT_BRIEF tag one can provide an optional one line description
4444
# for a project that appears at the top of each page and should give viewer a

0 commit comments

Comments
 (0)