Skip to content

Commit

Permalink
calculate version number early in the build
Browse files Browse the repository at this point in the history
  • Loading branch information
hiran committed Oct 14, 2023
1 parent e45bc49 commit 26b9efc
Show file tree
Hide file tree
Showing 2 changed files with 89 additions and 22 deletions.
109 changes: 88 additions & 21 deletions .github/workflows/build-all.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

name: build-all

on:
Expand All @@ -22,11 +21,33 @@ jobs:
fetch-depth: 0
submodules: true

- name: Calculate version number and set OOLITE_VERSION
id: version
run: |
set -x
cd oolite
# Build version string,
# taking into account that we may have just two digits
VERSION=$(cat src/Cocoa/oolite-version.xcconfig | cut -d '=' -f 2)
VER_MAJ=$(echo ${VERSION} | cut -d. -f1)
VER_MIN=$(echo ${VERSION} | cut -d. -f2)
VER_REV=$(echo ${VERSION} | cut -d. -f3)
if [ "" == "${VER_REV}" ]
then
VER_REV="0"
fi
VER_DATE=$(date +%y%m%d)
VER_GITREV=$(git rev-list --count HEAD)
VER_GITHASH=$(git rev-parse --short=7 HEAD)
VER="${VER_MAJ}.${VER_MIN}.${VER_REV}.${VER_GITREV}-${VER_DATE}-${VER_GITHASH}"
echo "OOLITE_VERSION=${VER}" >> "$GITHUB_OUTPUT"
echo "OOLITE_VERSION=${VER}" >> Doc/OOLITE_VERSION.txt
- name: generate PDFs
run: |
find oolite/Doc -name "*.odt" -exec soffice --headless --convert-to pdf:"writer_pdf_Export" --outdir oolite/Doc {} \;
zip oolite-doc.zip oolite/Doc/*.pdf
zip oolite-doc.zip oolite/Doc/*.pdf oolite/Doc/OOLITE_VERSION.txt
- name: Archive generated documentation
uses: actions/upload-artifact@v3
with:
Expand All @@ -40,7 +61,7 @@ jobs:
needs: [common-steps]
steps:
## This is for debugging only and helps developing the workflow.
#- name: Environment Variables
# - name: Environment Variables
# run: |
# printenv | sort

Expand All @@ -61,7 +82,7 @@ jobs:
with:
name: oolite-doc
path: artifacts

- name: Extract PDFs
run: |
unzip -u artifacts/oolite-doc.zip
Expand All @@ -70,15 +91,15 @@ jobs:
- name: show filesystem before build
run: |
find . -not -path "./oolite/deps/Windows-deps/*" -not -path "./oolite/Mac-specific/*" -not -path "./oolite/.git/*"
- name: compiling up to installer script (.run file)
run: |
cd oolite
source /usr/share/GNUstep/Makefiles/GNUstep.sh
make -f Makefile pkg-posix-nightly HOST_ARCH=$(uname -m)
## This is for debugging only and helps developing the workflow.
#- name: show filesystem after build
# - name: show filesystem after build
# run: |
# 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/*"

Expand All @@ -91,34 +112,34 @@ jobs:
run: |
NAME=$(basename oolite-nightly/oolite-*.run .run)
tar cvfz ${NAME}.tgz -C oolite-nightly .
# This is for debugging only and helps developing the workflow.
- name: show filesystem after installer
run: |
find . -not -path "./oolite/Mac-specific/*" -not -path "./oolite/deps/*" -not -path "./oolite/tests/*" -not -path "./oolite/.git/*"
- name: Archive build tar ball
uses: actions/upload-artifact@v3
with:
name: oolite-linux-nightly
path: |
oolite-*.tgz
retention-days: 5


build-windows:
runs-on: windows-latest
needs: [common-steps]
steps:
## This is for debugging only and helps developing the workflow.
#- name: Environment Variables
# - name: Environment Variables
# run: |
# Get-ChildItem Env: | Sort Name

- name: Checkout DevelopmentEnvironment
uses: actions/checkout@v3
with:
repository: OoliteProject/oolite-windows-build-env
repository: OoliteProject/oolite-windows-build-env
path: DevelopmentEnvironment

- name: Checkout Oolite
Expand All @@ -133,7 +154,7 @@ jobs:
with:
name: oolite-doc
path: artifacts

- name: Extract PDFs
run: |
unzip -u artifacts/oolite-doc.zip
Expand All @@ -147,7 +168,7 @@ jobs:
- name: Compile
shell: cmd
run: D:\a\oolite\oolite\DevelopmentEnvironment\gcc\Msys_x2\1.0\msys.cmd

# check http://aegidian.org/bb/viewtopic.php?p=281821#p281821
# this is for debug only; it creates huge logs and takes a long time to execute, yet you never know when you need it
- name: check filesystem
Expand All @@ -164,6 +185,7 @@ jobs:

build-doxygen:
runs-on: ubuntu-latest
needs: [common-steps]
steps:
- name: Checkout Oolite
uses: actions/checkout@v3
Expand All @@ -172,24 +194,45 @@ jobs:
fetch-depth: 0
submodules: true

- name: Download artifacts
uses: actions/download-artifact@v3
with:
name: oolite-doc
path: artifacts

- name: Extract artifacts
run: |
unzip -u artifacts/oolite-doc.zip
- name: set version
id: version
run: |
OOLITE_VERSION=$(cat oolite/Doc/OOLITE_VERSION.txt | cut -d= -f2)
echo "OOLITE_VERSION=${OOLITE_VERSION}" >> "$GITHUB_OUTPUT"
sed -i -e "/PROJECT_NUMBER\s*=/ s/=.*/=${OOLITE_VERSION}/" oolite/Doxyfile
cat oolite/Doxyfile
- name: Run doxygen
uses: mattnotmitt/doxygen-action@v1.9.5
with:
working-directory: oolite
# OOLITE_VERSION: ${{ steps.version.outputs.OOLITE_VERSION }}

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

- name: create tar ball
run: |
tar cvfz oolite-apidoc.tgz -C oolite doxygen
tar cvfz oolite-apidoc-${{ steps.version.outputs.OOLITE_VERSION }}.tgz -C oolite doxygen
# This is for debugging only and helps developing the workflow.
- name: Environment Variables 2
run: |
find . -not -path "./oolite/deps/*" -not -path "./oolite/Mac-specific/*" -not -path "./oolite/.git/*"
- name: Archive build tar ball
uses: actions/upload-artifact@v3
with:
Expand All @@ -203,7 +246,7 @@ jobs:
runs-on: ubuntu-latest
steps:
## This is for debugging only and helps developing the workflow.
#- name: Environment Variables
# - name: Environment Variables
# run: |
# printenv | sort

Expand All @@ -216,7 +259,30 @@ jobs:
- name: show filesystem after download
run: |
find .
- name: Extract artifacts
run: |
ls -l artifacts
unzip -u artifacts/oolite-doc/oolite-doc.zip
- name: set version
id: version
run: |
OOLITE_VERSION=$(cat oolite/Doc/OOLITE_VERSION.txt | cut -d= -f2)
echo "OOLITE_VERSION=${OOLITE_VERSION}" >> "$GITHUB_OUTPUT"
- name: Remove old prereleases
if: github.ref != 'refs/heads/master'
uses: s00d/delete-older-releases@0.2.1
with:
# repo: <owner>/<repoName> # defaults to current repo
keep_latest: 7
# delete_tag_pattern: v\d+\.\d+\.\d+-.*
delete_type: 'prerelease'
# delete_branch: '${{ github.ref_name }}'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

# For changes on master branch, create a new release.
# It should move the 'latest' tag automatically.
- name: Create Release
Expand All @@ -225,9 +291,10 @@ jobs:
uses: "marvinpinto/action-automatic-releases@latest"
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
automatic_release_tag: "latest"
# automatic_release_tag: "latest"
automatic_release_tag: "${{ steps.version.outputs.OOLITE_VERSION }}"
prerelease: true
title: "Oolite Nightly"
title: "Oolite ${{ steps.version.outputs.OOLITE_VERSION }}"
files: |
artifacts/oolite-documentation-nightly/oolite-*.tgz
artifacts/oolite-linux-nightly/oolite-*.tgz
Expand Down
2 changes: 1 addition & 1 deletion Doxyfile
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ PROJECT_NAME = "Oolite"
# could be handy for archiving the generated documentation or if some version
# control system is used.

PROJECT_NUMBER =
PROJECT_NUMBER = $(OOLITE_VERSION)

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

0 comments on commit 26b9efc

Please sign in to comment.