From 6fc83107054b22226e440d6da8d505763dcd5d65 Mon Sep 17 00:00:00 2001 From: =Michael Keller Date: Sat, 11 May 2024 17:33:54 +1200 Subject: [PATCH] CICD: Improve Workflows. Make multiple improvements to the existing workflows: - create a shared custom action to deal with version number tracking and generation; - use this action to add the branch name to the version for pull request builds; - create a shared workflow for all debian-ish builds to avoid re-use by copy / paste; - remove potential security risks by eliminating the use of pre-evaluated expressions (`${{ ... }}`) inside scripts; - update outdated GitHub action versions; - improve the consistency by renaming scripts acording to have a `.sh` extension; - improve naming of generated artefacts for pull requests to include the correct version. @dirkh: Unfortunately this is potentially going to break builds when it is merged, as there is no good way to 'test' a merge build short of merging. We'll just have to deal with the fallout of it in a follow-up pull request. Signed-off-by: Michael Keller --- .github/actions/manage-version/action.yml | 56 ++++++++++ .github/workflows/android-dockerimage.yml | 8 +- .github/workflows/android.yml | 59 ++++++----- .github/workflows/codeql-analysis.yml | 17 ++- .github/workflows/coverity-scan.yml | 20 ++-- .github/workflows/documentation.yml | 3 + .github/workflows/fedora-copr-build.yml | 20 ++-- .github/workflows/ios.yml | 22 ++-- .github/workflows/linux-debian-generic.yml | 100 ++++++++++++++++++ .../workflows/linux-debian-trixie-5.15.yml | 93 +--------------- .github/workflows/linux-fedora-35-qt6.yml | 25 +++-- .github/workflows/linux-snap.yml | 14 +-- .../linux-ubuntu-16.04-5.12-appimage.yml | 54 ++++------ .github/workflows/linux-ubuntu-20.04-5.15.yml | 76 +------------ .github/workflows/linux-ubuntu-22.04-5.15.yml | 93 +--------------- .github/workflows/linux-ubuntu-24.04-5.15.yml | 93 +--------------- .github/workflows/mac.yml | 28 ++--- .github/workflows/post-releasenotes.yml | 25 +++-- .github/workflows/ubuntu-launchpad-build.yml | 15 +-- .github/workflows/windows-mxe-dockerimage.yml | 8 +- .github/workflows/windows.yml | 33 +++--- CMakeLists.txt | 2 +- cmake/Modules/version.cmake | 6 +- packaging/android/qmake-build.sh | 4 +- packaging/copr/make-package.sh | 2 +- packaging/ios/build.sh | 6 +- packaging/macosx/make-package.sh | 2 +- packaging/ubuntu/make-package.sh | 2 +- scripts/{check-version => check-version.sh} | 2 +- scripts/{get-version => get-version.sh} | 41 +++---- smtk-import/cmake/Modules/version.cmake | 4 +- snap/snapcraft.yaml | 2 +- 32 files changed, 399 insertions(+), 536 deletions(-) create mode 100644 .github/actions/manage-version/action.yml create mode 100644 .github/workflows/linux-debian-generic.yml rename scripts/{check-version => check-version.sh} (97%) rename scripts/{get-version => get-version.sh} (76%) diff --git a/.github/actions/manage-version/action.yml b/.github/actions/manage-version/action.yml new file mode 100644 index 000000000..98c5fcb3c --- /dev/null +++ b/.github/actions/manage-version/action.yml @@ -0,0 +1,56 @@ +name: Manage the Subsurface CICD versioning + +inputs: + no-increment: + description: Only get the current version, do not increment it even for pushevents + default: false + nightly-builds-secret: + description: The secret to access the nightly builds repository + default: '' + +outputs: + version: + description: The long form version number + value: ${{ steps.version_number.outputs.version }} + buildnr: + description: The build number + value: ${{ steps.version_number.outputs.buildnr }} + +runs: + using: composite + steps: + - name: atomically create or retrieve the build number and assemble release notes for a push (i.e. merging of a pull request) + if: github.event_name == 'push' && ! inputs.no-increment + env: + NIGHTLY_BUILDS_SECRET: ${{ inputs.nightly-builds-secret }} + shell: bash + run: | + if [ -z "$NIGHTLY_BUILDS_SECRET" ]; then + echo "Need to supply the secret for the nightly-builds repository to increment the version number, aborting." + exit 1 + fi + scripts/get-atomic-buildnr.sh $GITHUB_SHA $NIGHTLY_BUILDS_SECRET "CICD-release" + + - name: retrieve the current version number in all other cases + if: github.event_name != 'push' || inputs.no-increment + env: + PULL_REQUEST_BRANCH: ${{ github.event.pull_request.head.ref }} + shell: bash + run: | + echo "-pull-request-$PULL_REQUEST_BRANCH" > latest-subsurface-buildnumber-extension + + - name: store version number for the build + id: version_number + env: + PULL_REQUEST_HEAD_SHA: ${{ github.event.pull_request.head.sha }} + shell: bash + run: | + git config --global --add safe.directory $GITHUB_WORKSPACE + # For a pull request we need the information from the pull request branch + # and not from the merge branch on the pull request + git checkout $PULL_REQUEST_HEAD_SHA + version=$(scripts/get-version.sh) + echo "version=$version" >> $GITHUB_OUTPUT + buildnr=$(scripts/get-version.sh 1) + echo "buildnr=$buildnr" >> $GITHUB_OUTPUT + git checkout $GITHUB_SHA diff --git a/.github/workflows/android-dockerimage.yml b/.github/workflows/android-dockerimage.yml index 6827ef8a8..73919e551 100644 --- a/.github/workflows/android-dockerimage.yml +++ b/.github/workflows/android-dockerimage.yml @@ -15,17 +15,17 @@ jobs: VERSION: ${{ '5.15.2' }} # the version numbers here is based on the Qt version, the third digit is the rev of the docker image steps: - - uses: actions/checkout@v1 + - uses: actions/checkout@v4 - name: Build the name for the docker image id: build_name run: | - v=${{ env.VERSION }} - b=${{ github.ref }} # -BRANCH suffix, unless the branch is master + v=$VERSION + b=$GITHUB_REF # -BRANCH suffix, unless the branch is master b=${b/refs\/heads\//} b=${b,,} # the name needs to be all lower case if [ $b = "master" ] ; then b="" ; else b="-$b" ; fi - echo "NAME=subsurface/android-build${b}:${v}" >> $GITHUB_OUTPUT + echo "NAME=$GITHUB_REPOSITORY_OWNER/android-build${b}:${v}" >> $GITHUB_OUTPUT - name: Build and Publish Linux Docker image to Dockerhub uses: elgohr/Publish-Docker-Github-Action@v5 diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml index 8302d1620..37cdfb4bd 100644 --- a/.github/workflows/android.yml +++ b/.github/workflows/android.yml @@ -1,4 +1,5 @@ name: Android + on: push: paths-ignore: @@ -11,45 +12,44 @@ on: branches: - master - jobs: - buildAndroid: - runs-on: ubuntu-latest + build: env: - BUILD_ROOT: ${{ github.workspace }}/.. KEYSTORE_FILE: ${{ github.workspace }}/../subsurface.keystore + runs-on: ubuntu-latest container: image: docker://subsurface/android-build:5.15.2 steps: - name: checkout sources uses: actions/checkout@v4 + with: + fetch-depth: 0 + submodules: recursive - - name: atomically create or retrieve the build number and assemble release notes + - name: set the version information id: version_number - if: github.event_name == 'push' - run: | - bash scripts/get-atomic-buildnr.sh ${{ github.sha }} ${{ secrets.NIGHTLY_BUILDS }} "CICD-release" - version=$(cat release-version) - echo "version=$version" >> $GITHUB_OUTPUT - - - name: store dummy version and build number for non-push build runs - if: github.event_name != 'push' - run: | - echo "100" > latest-subsurface-buildnumber - echo "CICD-pull-request" > latest-subsurface-buildnumber-extension + uses: ./.github/actions/manage-version + with: + nightly-builds-secret: ${{ secrets.NIGHTLY_BUILDS }} - name: set up the keystore if: github.event_name == 'push' + env: + ANDROID_KEYSTORE_BASE64: ${{ secrets.ANDROID_KEYSTORE_BASE64 }} run: | - echo "${{ secrets.ANDROID_KEYSTORE_BASE64 }}" | base64 -d > $KEYSTORE_FILE + echo "$ANDROID_KEYSTORE_BASE64" | base64 -d > $KEYSTORE_FILE - name: run build id: build + env: + ANDROID_KEYSTORE_PASSWORD: pass:${{ secrets.ANDROID_KEYSTORE_PASSWORD }} + KEYSTORE_ALIAS: ${{ secrets.ANDROID_KEYSTORE_ALIAS }} + BUILDNR: ${{ steps.version_number.outputs.buildnr }} run: | # this is rather awkward, but it allows us to use the preinstalled # Android and Qt versions with relative paths - cd $BUILD_ROOT + cd .. ln -s /android/5.15.* . ln -s /android/build-tools . ln -s /android/cmdline-tools . @@ -62,12 +62,20 @@ jobs: git config --global --add safe.directory $GITHUB_WORKSPACE git config --global --add safe.directory $GITHUB_WORKSPACE/libdivecomputer # get the build number via curl so this works both for a pull request as well as a push - BUILDNR=$(curl -q https://raw.githubusercontent.com/subsurface/nightly-builds/main/latest-subsurface-buildnumber) export OUTPUT_DIR="$GITHUB_WORKSPACE" - export KEYSTORE_FILE="$KEYSTORE_FILE" - export KEYSTORE_PASSWORD="pass:${{ secrets.ANDROID_KEYSTORE_PASSWORD }}" - export KEYSTORE_ALIAS="${{ secrets.ANDROID_KEYSTORE_ALIAS }}" - bash -x ./subsurface/packaging/android/qmake-build.sh -buildnr ${BUILDNR} + bash -x ./subsurface/packaging/android/qmake-build.sh -buildnr $BUILDNR + + - name: delete the keystore + if: github.event_name == 'push' + run: | + rm $KEYSTORE_FILE + + - name: publish pull request artifacts + if: github.event_name == 'pull_request' + uses: actions/upload-artifact@v4 + with: + name: Subsurface-Android-${{ steps.version_number.outputs.version }} + path: Subsurface-mobile-*.apk # only publish a 'release' on push events (those include merging a PR) - name: upload binaries @@ -81,8 +89,3 @@ jobs: fail_on_unmatched_files: true files: | Subsurface-mobile-${{ steps.version_number.outputs.version }}.apk - - - name: delete the keystore - if: github.event_name == 'push' - run: | - rm $KEYSTORE_FILE diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 0937a662a..bfdd46958 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -25,15 +25,14 @@ jobs: matrix: # Override automatic language detection by changing the below list # Supported options are ['csharp', 'cpp', 'go', 'java', 'javascript', 'python'] - language: ['cpp', 'javascript'] + language: ['c-cpp', 'javascript-typescript'] steps: - name: Checkout repository uses: actions/checkout@v4 with: - # We must fetch at least the immediate parents so that if this is - # a pull request then we can checkout the head. - fetch-depth: 2 + fetch-depth: 0 + submodules: recursive - name: get container ready for build run: | @@ -51,7 +50,7 @@ jobs: # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL - uses: github/codeql-action/init@v2 + uses: github/codeql-action/init@v3 with: languages: ${{ matrix.language }} # If you wish to specify custom queries, you can do so here or in a config file. @@ -60,13 +59,11 @@ jobs: # queries: ./path/to/local/query, your-org/your-repo/queries@main - name: Build - env: - SUBSURFACE_REPO_PATH: ${{ github.workspace }} run: | cd .. - git config --global --add safe.directory ${SUBSURFACE_REPO_PATH} - git config --global --add safe.directory ${SUBSURFACE_REPO_PATH}/libdivecomputer + git config --global --add safe.directory $GITHUB_WORKSPACE + git config --global --add safe.directory $GITHUB_WORKSPACE/libdivecomputer bash -e -x subsurface/scripts/build.sh -desktop -build-with-webkit - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v2 + uses: github/codeql-action/analyze@v3 diff --git a/.github/workflows/coverity-scan.yml b/.github/workflows/coverity-scan.yml index e70f443ac..cf23c7a35 100644 --- a/.github/workflows/coverity-scan.yml +++ b/.github/workflows/coverity-scan.yml @@ -1,4 +1,5 @@ name: Coverity Scan Linux Qt 5.9 + on: schedule: - cron: '0 18 * * *' # Daily at 18:00 UTC @@ -11,7 +12,10 @@ jobs: steps: - name: checkout sources - uses: actions/checkout@v1 + uses: actions/checkout@v4 + with: + fetch-depth: 0 + submodules: recursive - name: add build dependencies run: | @@ -30,11 +34,15 @@ jobs: qtquickcontrols2-5-dev libbluetooth-dev libmtp-dev - name: configure environment - env: - SUBSURFACE_REPO_PATH: ${{ github.workspace }} run: | - git config --global --add safe.directory ${SUBSURFACE_REPO_PATH} - git config --global --add safe.directory ${SUBSURFACE_REPO_PATH}/libdivecomputer + git config --global --add safe.directory $GITHUB_WORKSPACE + git config --global --add safe.directory $GITHUB_WORKSPACE/libdivecomputer + + - name: get the version information + id: version_number + uses: ./.github/actions/manage-version + with: + no-increment: true - name: run coverity scan uses: vapier/coverity-scan-action@v1 @@ -44,5 +52,5 @@ jobs: email: glance@acc.umu.se command: subsurface/scripts/build.sh -desktop -build-with-webkit working-directory: ${{ github.workspace }}/.. - version: $(/scripts/get-version) + version: ${{ steps.version_number.outputs.version }} description: Automatic scan on github actions diff --git a/.github/workflows/documentation.yml b/.github/workflows/documentation.yml index b9014b820..f07fd0af9 100644 --- a/.github/workflows/documentation.yml +++ b/.github/workflows/documentation.yml @@ -26,6 +26,9 @@ jobs: - name: Checkout Sources uses: actions/checkout@v4 + with: + fetch-depth: 0 + submodules: recursive - name: Process the Documentation id: process_documentation diff --git a/.github/workflows/fedora-copr-build.yml b/.github/workflows/fedora-copr-build.yml index 7c57ef14d..a5e7ba830 100644 --- a/.github/workflows/fedora-copr-build.yml +++ b/.github/workflows/fedora-copr-build.yml @@ -11,12 +11,16 @@ jobs: setup-build: name: Submit build to Fedora COPR # this seems backwards, but we want to run under Fedora, but Github doesn' support that - container: fedora:latest runs-on: ubuntu-latest + container: + image: fedora:latest steps: - name: Check out sources - uses: actions/checkout@v1 + uses: actions/checkout@v4 + with: + fetch-depth: 0 + submodules: recursive - name: Setup build dependencies in the Fedora container run: | @@ -28,13 +32,11 @@ jobs: git config --global --add safe.directory /__w/subsurface/subsurface git config --global --add safe.directory /__w/subsurface/subsurface/libdivecomputer - - name: atomically create or retrieve the build number + - name: set the version information id: version_number - if: github.event_name == 'push' - run: | - bash scripts/get-atomic-buildnr.sh ${{ github.sha }} ${{ secrets.NIGHTLY_BUILDS }} "CICD-release" - version=$(cat release-version) - echo "version=$version" >> $GITHUB_OUTPUT + uses: ./.github/actions/manage-version + with: + nightly-builds-secret: ${{ secrets.NIGHTLY_BUILDS }} - name: Setup API token for copr-cli env: @@ -53,5 +55,5 @@ jobs: - name: run the copr build script run: | cd .. - bash -x subsurface/packaging/copr/make-package.sh ${{ github.ref_name }} + bash -x subsurface/packaging/copr/make-package.sh $GITHUB_REF_NAME diff --git a/.github/workflows/ios.yml b/.github/workflows/ios.yml index f9819fa05..169dade1e 100644 --- a/.github/workflows/ios.yml +++ b/.github/workflows/ios.yml @@ -1,4 +1,5 @@ name: iOS + on: push: paths-ignore: @@ -19,7 +20,10 @@ jobs: run: sudo xcode-select -s "/Applications/Xcode_11.7.app" - name: checkout sources - uses: actions/checkout@v1 + uses: actions/checkout@v4 + with: + fetch-depth: 0 + submodules: recursive - name: setup Homebrew run: brew install autoconf automake libtool pkg-config @@ -31,24 +35,24 @@ jobs: ref: main path: qt-ios - - name: store dummy version and build number for test build + - name: set the version information id: version_number - run: | - echo "100" > latest-subsurface-buildnumber - echo "CICD-test-build" > latest-subsurface-buildnumber-extension - version=$(scripts/get-version) - echo "version=$version" >> $GITHUB_OUTPUT + uses: ./.github/actions/manage-version + with: + nightly-builds-secret: ${{ secrets.NIGHTLY_BUILDS }} - name: build Subsurface-mobile for iOS + env: + VERSION: ${{ steps.version_number.outputs.version }} run: | - cd ${{ github.workspace }}/.. + cd .. git config --global --add safe.directory $GITHUB_WORKSPACE git config --global --add safe.directory $GITHUB_WORKSPACE/libdivecomputer export IOS_QT=$GITHUB_WORKSPACE/qt-ios echo "build for simulator" bash -x $GITHUB_WORKSPACE/packaging/ios/build.sh -simulator # We need this in order to be able to access the file and publish it - mv build-Subsurface-mobile-Qt_5_14_1_for_iOS-Release/Release-iphonesimulator/Subsurface-mobile.app ${{ github.workspace }}/Subsurface-mobile-${{ steps.version_number.outputs.version }}.app + mv build-Subsurface-mobile-Qt_5_14_1_for_iOS-Release/Release-iphonesimulator/Subsurface-mobile.app $GITHUB_WORKSPACE/Subsurface-mobile-$VERSION.app - name: publish artifacts uses: actions/upload-artifact@v4 diff --git a/.github/workflows/linux-debian-generic.yml b/.github/workflows/linux-debian-generic.yml new file mode 100644 index 000000000..d92fe19b6 --- /dev/null +++ b/.github/workflows/linux-debian-generic.yml @@ -0,0 +1,100 @@ +name: Generic workflow for Debian and derivatives + +on: + workflow_call: + inputs: + container-image: + required: true + type: string + +jobs: + build: + runs-on: ubuntu-latest + container: + image: ${{ inputs.container-image }} + + steps: + - name: get container ready for build + run: | + echo "--------------------------------------------------------------" + echo "update distro and install dependencies" + + apt-get update + apt-get dist-upgrade -y + DEBIAN_FRONTEND=noninteractive apt-get install -y -q \ + autoconf automake cmake g++ git libcrypto++-dev libcurl4-gnutls-dev \ + libgit2-dev libqt5qml5 libqt5quick5 libqt5svg5-dev \ + libqt5webkit5-dev libsqlite3-dev libssh2-1-dev libssl-dev libssl-dev \ + libtool libusb-1.0-0-dev libxml2-dev libxslt1-dev libzip-dev make \ + pkg-config qml-module-qtlocation qml-module-qtpositioning \ + qml-module-qtquick2 qt5-qmake qtchooser qtconnectivity5-dev \ + qtdeclarative5-dev qtdeclarative5-private-dev qtlocation5-dev \ + qtpositioning5-dev qtscript5-dev qttools5-dev qttools5-dev-tools \ + qtquickcontrols2-5-dev xvfb libbluetooth-dev libmtp-dev \ + mdbtools-dev + + git config --global user.email "ci@subsurface-divelog.org" + git config --global user.name "Subsurface CI" + git config --global --add safe.directory $GITHUB_WORKSPACE + git config --global --add safe.directory $GITHUB_WORKSPACE/libdivecomputer + # needs git from the previous step + - name: checkout sources + uses: actions/checkout@v4 + with: + fetch-depth: 0 + submodules: recursive + + - name: set the version information + id: version_number + uses: ./.github/actions/manage-version + with: + no-increment: true + + - name: build subsurface-mobile + run: | + echo "--------------------------------------------------------------" + echo "building mobile" + cd .. + bash -e -x subsurface/scripts/build.sh -mobile + + - name: test mobile build + run: | + echo "--------------------------------------------------------------" + echo "running tests for mobile" + + cd build-mobile/tests + # xvfb-run --auto-servernum ./TestGitStorage -v2 + xvfb-run --auto-servernum make check + + - name: build subsurface + run: | + echo "--------------------------------------------------------------" + echo "building desktop" + + # now build for the desktop version (including WebKit) + cd .. + bash -e -x subsurface/scripts/build.sh -desktop -build-with-webkit + + - name: test desktop build + run: | + echo "--------------------------------------------------------------" + echo "running tests for desktop" + cd build/tests + # xvfb-run --auto-servernum ./TestGitStorage -v2 + xvfb-run --auto-servernum make check + + - name: build subsurface-downloader + run: | + echo "--------------------------------------------------------------" + echo "building downloader" + cd .. + bash -e -x subsurface/scripts/build.sh -downloader + + - name: build smtk2ssrf + run: | + echo "--------------------------------------------------------------" + echo "building smtk2ssrf" + + # build smtk2ssrf (needs the artefacts generated by the subsurface build + cd .. + bash -e -x subsurface/scripts/smtk2ssrf-build.sh -y diff --git a/.github/workflows/linux-debian-trixie-5.15.yml b/.github/workflows/linux-debian-trixie-5.15.yml index 1da921d81..fea65ffc6 100644 --- a/.github/workflows/linux-debian-trixie-5.15.yml +++ b/.github/workflows/linux-debian-trixie-5.15.yml @@ -1,4 +1,5 @@ name: Debian trixie / Qt 5.15-- + on: push: paths-ignore: @@ -12,91 +13,7 @@ on: - master jobs: - build: - runs-on: ubuntu-latest - container: - image: debian:trixie - - steps: - - name: checkout sources - uses: actions/checkout@v1 - - - name: get container ready for build - env: - SUBSURFACE_REPO_PATH: ${{ github.workspace }} - run: | - echo "--------------------------------------------------------------" - echo "update distro and install dependencies" - - apt-get update - apt-get dist-upgrade -y - DEBIAN_FRONTEND=noninteractive apt-get install -y -q \ - autoconf automake cmake g++ git libcrypto++-dev libcurl4-gnutls-dev \ - libgit2-dev libqt5qml5 libqt5quick5 libqt5svg5-dev \ - libqt5webkit5-dev libsqlite3-dev libssh2-1-dev libssl-dev libssl-dev \ - libtool libusb-1.0-0-dev libxml2-dev libxslt1-dev libzip-dev make \ - pkg-config qml-module-qtlocation qml-module-qtpositioning \ - qml-module-qtquick2 qt5-qmake qtchooser qtconnectivity5-dev \ - qtdeclarative5-dev qtdeclarative5-private-dev qtlocation5-dev \ - qtpositioning5-dev qtscript5-dev qttools5-dev qttools5-dev-tools \ - qtquickcontrols2-5-dev xvfb libbluetooth-dev libmtp-dev \ - mdbtools-dev - - git config --global user.email "ci@subsurface-divelog.org" - git config --global user.name "Subsurface CI" - git config --global --add safe.directory ${SUBSURFACE_REPO_PATH} - git config --global --add safe.directory ${SUBSURFACE_REPO_PATH}/libdivecomputer - - - name: store dummy version and build number for test build - run: | - echo "100" > latest-subsurface-buildnumber - echo "CICD-test-build" > latest-subsurface-buildnumber-extension - - - name: build subsurface-mobile - run: | - echo "--------------------------------------------------------------" - echo "building mobile" - cd .. - bash -e -x subsurface/scripts/build.sh -mobile - - - name: test mobile build - run: | - echo "--------------------------------------------------------------" - echo "running tests for mobile" - - cd build-mobile/tests - # xvfb-run --auto-servernum ./TestGitStorage -v2 - xvfb-run --auto-servernum make check - - - name: build subsurface - run: | - echo "--------------------------------------------------------------" - echo "building desktop" - - # now build for the desktop version (including WebKit) - cd .. - bash -e -x subsurface/scripts/build.sh -desktop -build-with-webkit - - - name: test desktop build - run: | - echo "--------------------------------------------------------------" - echo "running tests for desktop" - cd build/tests - # xvfb-run --auto-servernum ./TestGitStorage -v2 - xvfb-run --auto-servernum make check - - - name: build subsurface-downloader - run: | - echo "--------------------------------------------------------------" - echo "building downloader" - cd .. - bash -e -x subsurface/scripts/build.sh -downloader - - - name: build smtk2ssrf - run: | - echo "--------------------------------------------------------------" - echo "building smtk2ssrf" - - # build smtk2ssrf (needs the artefacts generated by the subsurface build - cd .. - bash -e -x subsurface/scripts/smtk2ssrf-build.sh -y + do-build-test: + uses: ./.github/workflows/linux-debian-generic.yml + with: + container-image: debian:trixie diff --git a/.github/workflows/linux-fedora-35-qt6.yml b/.github/workflows/linux-fedora-35-qt6.yml index 65bf82411..6b323e4a4 100644 --- a/.github/workflows/linux-fedora-35-qt6.yml +++ b/.github/workflows/linux-fedora-35-qt6.yml @@ -1,4 +1,5 @@ name: Fedora 35 / Qt 6-- + on: push: paths-ignore: @@ -18,9 +19,6 @@ jobs: image: fedora:35 steps: - - name: checkout sources - uses: actions/checkout@v1 - - name: get container ready for build run: | echo "--------------------------------------------------------------" @@ -37,22 +35,27 @@ jobs: bluez-libs-devel libgit2-devel libzip-devel libmtp-devel \ xorg-x11-server-Xvfb - - name: store dummy version and build number for test build - run: | - echo "100" > latest-subsurface-buildnumber - echo "CICD-test-build" > latest-subsurface-buildnumber-extension + - name: checkout sources + uses: actions/checkout@v4 + with: + fetch-depth: 0 + submodules: recursive + + - name: set the version information + id: version_number + uses: ./.github/actions/manage-version + with: + no-increment: true - name: build Subsurface - env: - SUBSURFACE_REPO_PATH: ${{ github.workspace }} run: | echo "--------------------------------------------------------------" echo "building desktop" # now build for the desktop version (without WebKit) cd .. - git config --global --add safe.directory ${SUBSURFACE_REPO_PATH} - git config --global --add safe.directory ${SUBSURFACE_REPO_PATH}/libdivecomputer + git config --global --add safe.directory $GITHUB_WORKSPACE + git config --global --add safe.directory $GITHUB_WORKSPACE/libdivecomputer git config --global --get-all safe.directory bash -e -x subsurface/scripts/build.sh -desktop -build-with-qt6 diff --git a/.github/workflows/linux-snap.yml b/.github/workflows/linux-snap.yml index 293380c34..318a687b7 100644 --- a/.github/workflows/linux-snap.yml +++ b/.github/workflows/linux-snap.yml @@ -19,16 +19,16 @@ jobs: timeout-minutes: 60 steps: - name: Check out code - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: - # Needed for version determination to work fetch-depth: 0 + submodules: recursive - - name: atomically create or retrieve the build number + - name: set the version information id: version_number - if: github.event_name == 'push' - run: | - bash scripts/get-atomic-buildnr.sh ${{ github.sha }} ${{ secrets.NIGHTLY_BUILDS }} "CICD-release" + uses: ./.github/actions/manage-version + with: + nightly-builds-secret: ${{ secrets.NIGHTLY_BUILDS }} - name: store dummy version and build number for pull request if: github.event_name == 'pull_request' @@ -52,7 +52,7 @@ jobs: # Find common base between master and HEAD to use as cache key. git -c protocol.version=2 fetch --no-tags --prune --progress --no-recurse-submodules origin master - echo "key=$( git merge-base origin/master ${{ github.sha }} )" >> $GITHUB_OUTPUT + echo "key=$( git merge-base origin/master $GITHUB_SHA )" >> $GITHUB_OUTPUT - name: CCache uses: actions/cache@v3 diff --git a/.github/workflows/linux-ubuntu-16.04-5.12-appimage.yml b/.github/workflows/linux-ubuntu-16.04-5.12-appimage.yml index ac0b353e4..616dba389 100644 --- a/.github/workflows/linux-ubuntu-16.04-5.12-appimage.yml +++ b/.github/workflows/linux-ubuntu-16.04-5.12-appimage.yml @@ -1,4 +1,5 @@ name: Ubuntu 16.04 / Qt 5.15-- for AppImage + on: push: paths-ignore: @@ -18,9 +19,6 @@ jobs: image: ubuntu:16.04 steps: - - name: checkout sources - uses: actions/checkout@v1 - - name: get container ready for build run: | echo "--------------------------------------------------------------" @@ -45,8 +43,8 @@ jobs: add-apt-repository -y ppa:savoury1/gtk-xenial add-apt-repository -y ppa:savoury1/qt-xenial add-apt-repository -y ppa:savoury1/kde-xenial - add-apt-repository -y ppa:mayeut-github/devtoolset-10 - add-apt-repository -y 'deb https://apt.kitware.com/ubuntu/ xenial main' + add-apt-repository -y ppa:savoury1/backports + add-apt-repository -y ppa:savoury1/build-tools apt-get update apt-get dist-upgrade -y DEBIAN_FRONTEND=noninteractive apt-get install -y -q \ @@ -58,27 +56,23 @@ jobs: qml-module-qtquick2 qt5-qmake qtchooser qtconnectivity5-dev \ qtdeclarative5-dev qtdeclarative5-private-dev qtlocation5-dev \ qtpositioning5-dev qtscript5-dev qttools5-dev qttools5-dev-tools \ - qtquickcontrols2-5-dev xvfb libbluetooth-dev libmtp-dev + qtquickcontrols2-5-dev xvfb libbluetooth-dev libmtp-dev liblzma-dev update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-9 60 \ --slave /usr/bin/g++ g++ /usr/bin/g++-9 - - name: atomically create or retrieve the build number and assemble release notes - id: version_number - if: github.event_name == 'push' - run: | - bash ./scripts/get-atomic-buildnr.sh ${{ github.sha }} ${{ secrets.NIGHTLY_BUILDS }} "CICD-release" - version=$(cat release-version) - echo "version=$version" >> $GITHUB_OUTPUT + - name: checkout sources + # We cannot update this as glibc on 16.04 is too old for node 20. + uses: actions/checkout@v3 + with: + fetch-depth: 0 + submodules: recursive - - name: store dummy version and build number for pull request - id: pull_request_version_number - if: github.event_name == 'pull_request' - run: | - echo "100" > latest-subsurface-buildnumber - echo "CICD-pull-request" > latest-subsurface-buildnumber-extension - version=$(scripts/get-version) - echo "version=$version" >> $GITHUB_OUTPUT + - name: set the version information + id: version_number + uses: ./.github/actions/manage-version + with: + nightly-builds-secret: ${{ secrets.NIGHTLY_BUILDS }} - name: build Subsurface run: | @@ -98,6 +92,8 @@ jobs: xvfb-run --auto-servernum make check - name: build appimage + env: + VERSION: ${{ steps.version_number.outputs.version }} run: | echo "--------------------------------------------------------------" echo "assembling AppImage" @@ -131,22 +127,18 @@ jobs: ./linuxdeployqt*.AppImage --appimage-extract-and-run ./appdir/usr/share/applications/*.desktop -exclude-libs=libdbus-1.so.3 -appimage -qmldir=./subsurface/stats -qmldir=./subsurface/map-widget/ -verbose=2 # copy AppImage to the calling VM - # with GitHub Actions the /${GITHUB_WORKSPACE} directory is the current working directory at the start of a step - cp Subsurface*.AppImage* /${GITHUB_WORKSPACE}/Subsurface.AppImage + # with GitHub Actions the $GITHUB_WORKSPACE directory is the current working directory at the start of a step + cp Subsurface*.AppImage* $GITHUB_WORKSPACE/Subsurface-$VERSION.AppImage - name: PR artifacts if: github.event_name == 'pull_request' + # We cannot update this as glibc on 16.04 is too old for node 20. uses: actions/upload-artifact@v3 with: - name: Subsurface-Linux-AppImage-${{ steps.pull_request_version_number.outputs.version }} - path: Subsurface.AppImage + name: Subsurface-Linux-AppImage-${{ steps.version_number.outputs.version }} + path: Subsurface-*.AppImage compression-level: 0 - - name: prepare release artifacts - if: github.event_name == 'push' - run: | - mv Subsurface.AppImage Subsurface-v${{ steps.version_number.outputs.version }}.AppImage - # only publish a 'release' on push events (those include merging a PR) - name: upload binaries if: github.event_name == 'push' @@ -158,4 +150,4 @@ jobs: prerelease: false fail_on_unmatched_files: true files: | - ./Subsurface*.AppImage + ./Subsurface-*.AppImage diff --git a/.github/workflows/linux-ubuntu-20.04-5.15.yml b/.github/workflows/linux-ubuntu-20.04-5.15.yml index a7c5686b6..376649aab 100644 --- a/.github/workflows/linux-ubuntu-20.04-5.15.yml +++ b/.github/workflows/linux-ubuntu-20.04-5.15.yml @@ -1,4 +1,5 @@ name: Ubuntu 20.04 / Qt 5.12-- + on: push: paths-ignore: @@ -12,74 +13,7 @@ on: - master jobs: - build: - runs-on: ubuntu-latest - container: - image: ubuntu:20.04 - - steps: - - name: checkout sources - uses: actions/checkout@v1 - - - name: get container ready for build - run: | - echo "--------------------------------------------------------------" - echo "update distro and install dependencies" - - apt-get update - apt-get dist-upgrade -y - DEBIAN_FRONTEND=noninteractive apt-get install -y -q \ - autoconf automake cmake g++ git libcrypto++-dev libcurl4-gnutls-dev \ - libgit2-dev libqt5qml5 libqt5quick5 libqt5svg5-dev \ - libqt5webkit5-dev libsqlite3-dev libssh2-1-dev libssl-dev libssl-dev \ - libtool libusb-1.0-0-dev libxml2-dev libxslt1-dev libzip-dev make \ - pkg-config qml-module-qtlocation qml-module-qtpositioning \ - qml-module-qtquick2 qt5-qmake qtchooser qtconnectivity5-dev \ - qtdeclarative5-dev qtdeclarative5-private-dev qtlocation5-dev \ - qtpositioning5-dev qtscript5-dev qttools5-dev qttools5-dev-tools \ - qtquickcontrols2-5-dev xvfb libbluetooth-dev libmtp-dev - - - name: store dummy version and build number for test build - run: | - echo "100" > latest-subsurface-buildnumber - echo "CICD-test-build" > latest-subsurface-buildnumber-extension - - - name: build Subsurface-mobile - env: - SUBSURFACE_REPO_PATH: ${{ github.workspace }} - run: | - echo "--------------------------------------------------------------" - echo "building mobile" - git config --global user.email "ci@subsurface-divelog.org" - git config --global user.name "Subsurface CI" - git config --global --add safe.directory ${SUBSURFACE_REPO_PATH} - git config --global --add safe.directory ${SUBSURFACE_REPO_PATH}/libdivecomputer - cd .. - bash -e -x subsurface/scripts/build.sh -mobile - - - name: test mobile build - run: | - echo "--------------------------------------------------------------" - echo "running tests for mobile" - - cd build-mobile/tests - # xvfb-run --auto-servernum ./TestGitStorage -v2 - xvfb-run --auto-servernum make check - - - name: build Subsurface - run: | - echo "--------------------------------------------------------------" - echo "building desktop" - - # now build for the desktop version (including WebKit) - cd .. - bash -e -x subsurface/scripts/build.sh -desktop -build-with-webkit - - - name: test desktop build - run: | - echo "--------------------------------------------------------------" - echo "running tests for desktop" - cd build/tests - # xvfb-run --auto-servernum ./TestGitStorage -v2 - xvfb-run --auto-servernum make check - + do-build-test: + uses: ./.github/workflows/linux-debian-generic.yml + with: + container-image: ubuntu:20.04 diff --git a/.github/workflows/linux-ubuntu-22.04-5.15.yml b/.github/workflows/linux-ubuntu-22.04-5.15.yml index 730326a42..6fe086a6c 100644 --- a/.github/workflows/linux-ubuntu-22.04-5.15.yml +++ b/.github/workflows/linux-ubuntu-22.04-5.15.yml @@ -1,4 +1,5 @@ name: Ubuntu 22.04 / Qt 5.15-- + on: push: paths-ignore: @@ -12,91 +13,7 @@ on: - master jobs: - build: - runs-on: ubuntu-latest - container: - image: ubuntu:22.04 - - steps: - - name: checkout sources - uses: actions/checkout@v1 - - - name: get container ready for build - env: - SUBSURFACE_REPO_PATH: ${{ github.workspace }} - run: | - echo "--------------------------------------------------------------" - echo "update distro and install dependencies" - - apt-get update - apt-get dist-upgrade -y - DEBIAN_FRONTEND=noninteractive apt-get install -y -q \ - autoconf automake cmake g++ git libcrypto++-dev libcurl4-gnutls-dev \ - libgit2-dev libqt5qml5 libqt5quick5 libqt5svg5-dev \ - libqt5webkit5-dev libsqlite3-dev libssh2-1-dev libssl-dev libssl-dev \ - libtool libusb-1.0-0-dev libxml2-dev libxslt1-dev libzip-dev make \ - pkg-config qml-module-qtlocation qml-module-qtpositioning \ - qml-module-qtquick2 qt5-qmake qtchooser qtconnectivity5-dev \ - qtdeclarative5-dev qtdeclarative5-private-dev qtlocation5-dev \ - qtpositioning5-dev qtscript5-dev qttools5-dev qttools5-dev-tools \ - qtquickcontrols2-5-dev xvfb libbluetooth-dev libmtp-dev \ - mdbtools-dev - - git config --global user.email "ci@subsurface-divelog.org" - git config --global user.name "Subsurface CI" - git config --global --add safe.directory ${SUBSURFACE_REPO_PATH} - git config --global --add safe.directory ${SUBSURFACE_REPO_PATH}/libdivecomputer - - - name: store dummy version and build number for test build - run: | - echo "100" > latest-subsurface-buildnumber - echo "CICD-test-build" > latest-subsurface-buildnumber-extension - - - name: build subsurface-mobile - run: | - echo "--------------------------------------------------------------" - echo "building mobile" - cd .. - bash -e -x subsurface/scripts/build.sh -mobile - - - name: test mobile build - run: | - echo "--------------------------------------------------------------" - echo "running tests for mobile" - - cd build-mobile/tests - # xvfb-run --auto-servernum ./TestGitStorage -v2 - xvfb-run --auto-servernum make check - - - name: build subsurface - run: | - echo "--------------------------------------------------------------" - echo "building desktop" - - # now build for the desktop version (including WebKit) - cd .. - bash -e -x subsurface/scripts/build.sh -desktop -build-with-webkit - - - name: test desktop build - run: | - echo "--------------------------------------------------------------" - echo "running tests for desktop" - cd build/tests - # xvfb-run --auto-servernum ./TestGitStorage -v2 - xvfb-run --auto-servernum make check - - - name: build subsurface-downloader - run: | - echo "--------------------------------------------------------------" - echo "building downloader" - cd .. - bash -e -x subsurface/scripts/build.sh -downloader - - - name: build smtk2ssrf - run: | - echo "--------------------------------------------------------------" - echo "building smtk2ssrf" - - # build smtk2ssrf (needs the artefacts generated by the subsurface build - cd .. - bash -e -x subsurface/scripts/smtk2ssrf-build.sh -y + do-build-test: + uses: ./.github/workflows/linux-debian-generic.yml + with: + container-image: ubuntu:22.04 diff --git a/.github/workflows/linux-ubuntu-24.04-5.15.yml b/.github/workflows/linux-ubuntu-24.04-5.15.yml index 05c7295c3..3d9fb3945 100644 --- a/.github/workflows/linux-ubuntu-24.04-5.15.yml +++ b/.github/workflows/linux-ubuntu-24.04-5.15.yml @@ -1,4 +1,5 @@ name: Ubuntu 24.04 / Qt 5.15-- + on: push: paths-ignore: @@ -12,91 +13,7 @@ on: - master jobs: - build: - runs-on: ubuntu-latest - container: - image: ubuntu:24.04 - - steps: - - name: checkout sources - uses: actions/checkout@v1 - - - name: get container ready for build - env: - SUBSURFACE_REPO_PATH: ${{ github.workspace }} - run: | - echo "--------------------------------------------------------------" - echo "update distro and install dependencies" - - apt-get update - apt-get dist-upgrade -y - DEBIAN_FRONTEND=noninteractive apt-get install -y -q \ - autoconf automake cmake g++ git libcrypto++-dev libcurl4-gnutls-dev \ - libgit2-dev libqt5qml5 libqt5quick5 libqt5svg5-dev \ - libqt5webkit5-dev libsqlite3-dev libssh2-1-dev libssl-dev libssl-dev \ - libtool libusb-1.0-0-dev libxml2-dev libxslt1-dev libzip-dev make \ - pkg-config qml-module-qtlocation qml-module-qtpositioning \ - qml-module-qtquick2 qt5-qmake qtchooser qtconnectivity5-dev \ - qtdeclarative5-dev qtdeclarative5-private-dev qtlocation5-dev \ - qtpositioning5-dev qtscript5-dev qttools5-dev qttools5-dev-tools \ - qtquickcontrols2-5-dev xvfb libbluetooth-dev libmtp-dev \ - mdbtools-dev - - git config --global user.email "ci@subsurface-divelog.org" - git config --global user.name "Subsurface CI" - git config --global --add safe.directory ${SUBSURFACE_REPO_PATH} - git config --global --add safe.directory ${SUBSURFACE_REPO_PATH}/libdivecomputer - - - name: store dummy version and build number for test build - run: | - echo "100" > latest-subsurface-buildnumber - echo "CICD-test-build" > latest-subsurface-buildnumber-extension - - - name: build subsurface-mobile - run: | - echo "--------------------------------------------------------------" - echo "building mobile" - cd .. - bash -e -x subsurface/scripts/build.sh -mobile - - - name: test mobile build - run: | - echo "--------------------------------------------------------------" - echo "running tests for mobile" - - cd build-mobile/tests - # xvfb-run --auto-servernum ./TestGitStorage -v2 - xvfb-run --auto-servernum make check - - - name: build subsurface - run: | - echo "--------------------------------------------------------------" - echo "building desktop" - - # now build for the desktop version (including WebKit) - cd .. - bash -e -x subsurface/scripts/build.sh -desktop -build-with-webkit - - - name: test desktop build - run: | - echo "--------------------------------------------------------------" - echo "running tests for desktop" - cd build/tests - # xvfb-run --auto-servernum ./TestGitStorage -v2 - xvfb-run --auto-servernum make check - - - name: build subsurface-downloader - run: | - echo "--------------------------------------------------------------" - echo "building downloader" - cd .. - bash -e -x subsurface/scripts/build.sh -downloader - - - name: build smtk2ssrf - run: | - echo "--------------------------------------------------------------" - echo "building smtk2ssrf" - - # build smtk2ssrf (needs the artefacts generated by the subsurface build - cd .. - bash -e -x subsurface/scripts/smtk2ssrf-build.sh -y + do-build-test: + uses: ./.github/workflows/linux-debian-generic.yml + with: + container-image: ubuntu:24.04 diff --git a/.github/workflows/mac.yml b/.github/workflows/mac.yml index dde5289f0..88ebdb2b4 100644 --- a/.github/workflows/mac.yml +++ b/.github/workflows/mac.yml @@ -18,23 +18,9 @@ jobs: steps: - name: checkout sources uses: actions/checkout@v4 - - - name: atomically create or retrieve the build number and assemble release notes - id: version_number - if: github.event_name == 'push' - run: | - bash scripts/get-atomic-buildnr.sh ${{ github.sha }} ${{ secrets.NIGHTLY_BUILDS }} "CICD-release" - version=$(cat release-version) - echo "version=$version" >> $GITHUB_OUTPUT - - - name: store dummy version and build number for pull request - id: pull_request_version_number - if: github.event_name == 'pull_request' - run: | - echo "100" > latest-subsurface-buildnumber - echo "CICD-pull-request" > latest-subsurface-buildnumber-extension - version=$(scripts/get-version) - echo "version=$version" >> $GITHUB_OUTPUT + with: + fetch-depth: 0 + submodules: recursive - name: setup Homebrew run: brew install hidapi libxslt libjpg libmtp create-dmg confuse @@ -46,6 +32,12 @@ jobs: ref: main path: qt-mac + - name: set the version information + id: version_number + uses: ./.github/actions/manage-version + with: + nightly-builds-secret: ${{ secrets.NIGHTLY_BUILDS }} + - name: build Subsurface id: build run: | @@ -70,7 +62,7 @@ jobs: if: github.event_name == 'pull_request' uses: actions/upload-artifact@v4 with: - name: Subsurface-MacOS-${{ steps.pull_request_version_number.outputs.version }} + name: Subsurface-MacOS-${{ steps.version_number.outputs.version }} path: ${{ steps.build.outputs.dmg }} compression-level: 0 diff --git a/.github/workflows/post-releasenotes.yml b/.github/workflows/post-releasenotes.yml index 268d97cc6..c3b0bfd97 100644 --- a/.github/workflows/post-releasenotes.yml +++ b/.github/workflows/post-releasenotes.yml @@ -1,4 +1,5 @@ -name: Post Release +name: Post Release Notes + on: push: paths-ignore: @@ -6,24 +7,28 @@ on: branches: - master -env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - jobs: postRelease: runs-on: ubuntu-latest steps: - name: checkout sources uses: actions/checkout@v4 + with: + fetch-depth: 0 + submodules: recursive + + - name: set the version information + id: version_number + uses: ./.github/actions/manage-version + with: + nightly-builds-secret: ${{ secrets.NIGHTLY_BUILDS }} # since we are running this step on a pull request, we will skip build numbers in releases - - name: atomically create or retrieve the build number and assemble release notes - id: version_number + - name: assemble release notes + env: + EVENT_HEAD_COMMIT_ID: ${{ github.event.head_commit.id }} run: | - bash -x ./scripts/get-atomic-buildnr.sh ${{ github.sha }} ${{ secrets.NIGHTLY_BUILDS }} "CICD-release" - bash scripts/create-releasenotes.sh ${{ github.event.head_commit.id }} - version=$(cat release-version) - echo "version=$version" >> $GITHUB_OUTPUT + bash scripts/create-releasenotes.sh $EVENT_HEAD_COMMIT_ID # add a file containing the release title so it can be picked up and listed on the release page on our web server - name: publish release diff --git a/.github/workflows/ubuntu-launchpad-build.yml b/.github/workflows/ubuntu-launchpad-build.yml index 41941d259..2263e9773 100644 --- a/.github/workflows/ubuntu-launchpad-build.yml +++ b/.github/workflows/ubuntu-launchpad-build.yml @@ -15,13 +15,16 @@ jobs: steps: - name: Check out sources - uses: actions/checkout@v1 + uses: actions/checkout@v4 + with: + fetch-depth: 0 + submodules: recursive - - name: atomically create or retrieve the build number + - name: set the version information id: version_number - if: github.event_name == 'push' - run: | - bash scripts/get-atomic-buildnr.sh ${{ github.sha }} ${{ secrets.NIGHTLY_BUILDS }} "CICD-release" + uses: ./.github/actions/manage-version + with: + nightly-builds-secret: ${{ secrets.NIGHTLY_BUILDS }} - name: Setup build dependencies run: | @@ -48,5 +51,5 @@ jobs: - name: run the launchpad make-package script run: | cd .. - bash -x subsurface/packaging/ubuntu/make-package.sh ${{ github.ref_name }} + bash -x subsurface/packaging/ubuntu/make-package.sh $GITHUB_REF_NAME diff --git a/.github/workflows/windows-mxe-dockerimage.yml b/.github/workflows/windows-mxe-dockerimage.yml index cbaf7472e..a0478d1c5 100644 --- a/.github/workflows/windows-mxe-dockerimage.yml +++ b/.github/workflows/windows-mxe-dockerimage.yml @@ -16,17 +16,17 @@ jobs: mxe_sha: 'c0bfefc57a00fdf6cb5278263e21a478e47b0bf5' steps: - - uses: actions/checkout@v1 + - uses: actions/checkout@v4 - name: Build the name for the docker image id: build_name run: | - v=${{ env.VERSION }} - b=${{ github.ref }} # -BRANCH suffix, unless the branch is master + v=$VERSION + b=$GITHUB_REF # -BRANCH suffix, unless the branch is master b=${b/refs\/heads\//} b=${b,,} # the name needs to be all lower case if [ $b = "master" ] ; then b="" ; else b="-$b" ; fi - echo "NAME=${{ github.repository_owner }}/mxe-build${b}:${v}" >> $GITHUB_OUTPUT + echo "NAME=$GITHUB_REPOSITORY_OWNER/mxe-build${b}:${v}" >> $GITHUB_OUTPUT - name: Build and Publish Linux Docker image to Dockerhub uses: elgohr/Publish-Docker-Github-Action@v5 diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index 0e2716535..74500b917 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -1,4 +1,5 @@ name: Windows + on: push: paths-ignore: @@ -12,28 +13,23 @@ on: - master jobs: - buildWindows: + build: runs-on: ubuntu-latest container: image: docker://subsurface/mxe-build:3.1.0 steps: - name: checkout sources - uses: actions/checkout@v1 + uses: actions/checkout@v4 + with: + fetch-depth: 0 + submodules: recursive - - name: atomically create or retrieve the build number and assemble release notes + - name: set the version information id: version_number - if: github.event_name == 'push' - run: | - bash scripts/get-atomic-buildnr.sh ${{ github.sha }} ${{ secrets.NIGHTLY_BUILDS }} "CICD-release" - version=$(cat release-version) - echo "version=$version" >> $GITHUB_OUTPUT - - - name: store dummy version and build number for pull request - if: github.event_name == 'pull_request' - run: | - echo "100" > latest-subsurface-buildnumber - echo "CICD-pull-request" > latest-subsurface-buildnumber-extension + uses: ./.github/actions/manage-version + with: + nightly-builds-secret: ${{ secrets.NIGHTLY_BUILDS }} - name: get other dependencies env: @@ -53,6 +49,15 @@ jobs: bash -x subsurface/packaging/windows/in-container-build.sh 2>&1 | tee build.log grep "Built target installer" build.log + - name: publish pull request artifacts + if: github.event_name == 'pull_request' + uses: actions/upload-artifact@v4 + with: + name: Subsurface-Windows-${{ steps.version_number.outputs.version }} + path: | + subsurface*.exe* + smtk2ssrf*.exe + # only publish a 'release' on push events (those include merging a PR) - name: upload binaries if: github.event_name == 'push' diff --git a/CMakeLists.txt b/CMakeLists.txt index cacc1bbff..dfbf4e233 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -320,7 +320,7 @@ elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux") endif() elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin") execute_process( - COMMAND bash scripts/get-version + COMMAND bash scripts/get-version.sh WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} OUTPUT_VARIABLE SSRF_VERSION_STRING OUTPUT_STRIP_TRAILING_WHITESPACE diff --git a/cmake/Modules/version.cmake b/cmake/Modules/version.cmake index aa762c128..8c11f9269 100644 --- a/cmake/Modules/version.cmake +++ b/cmake/Modules/version.cmake @@ -1,20 +1,20 @@ execute_process( - COMMAND bash ${CMAKE_TOP_SRC_DIR}/scripts/get-version 4 + COMMAND bash ${CMAKE_TOP_SRC_DIR}/scripts/get-version.sh 4 WORKING_DIRECTORY ${CMAKE_TOP_SRC_DIR} OUTPUT_VARIABLE CANONICAL_VERSION_STRING_4 OUTPUT_STRIP_TRAILING_WHITESPACE ) execute_process( - COMMAND bash ${CMAKE_TOP_SRC_DIR}/scripts/get-version 3 + COMMAND bash ${CMAKE_TOP_SRC_DIR}/scripts/get-version.sh 3 WORKING_DIRECTORY ${CMAKE_TOP_SRC_DIR} OUTPUT_VARIABLE CANONICAL_VERSION_STRING_3 OUTPUT_STRIP_TRAILING_WHITESPACE ) execute_process( - COMMAND bash ${CMAKE_TOP_SRC_DIR}/scripts/get-version + COMMAND bash ${CMAKE_TOP_SRC_DIR}/scripts/get-version.sh WORKING_DIRECTORY ${CMAKE_TOP_SRC_DIR} OUTPUT_VARIABLE CANONICAL_VERSION_STRING OUTPUT_STRIP_TRAILING_WHITESPACE diff --git a/packaging/android/qmake-build.sh b/packaging/android/qmake-build.sh index 2f32ae4be..0bc40a091 100755 --- a/packaging/android/qmake-build.sh +++ b/packaging/android/qmake-build.sh @@ -86,9 +86,9 @@ mkdir -p "$BUILDROOT"/subsurface-mobile-build pushd "$BUILDROOT"/subsurface-mobile-build # set up the Subsurface versions by hand -CANONICALVERSION=$("$SUBSURFACE_SOURCE"/scripts/get-version) +CANONICALVERSION=$("$SUBSURFACE_SOURCE"/scripts/get-version.sh) echo "#define CANONICAL_VERSION_STRING \"$CANONICALVERSION\"" > ssrf-version.h -CANONICALVERSION_4=$("$SUBSURFACE_SOURCE"/scripts/get-version 4) +CANONICALVERSION_4=$("$SUBSURFACE_SOURCE"/scripts/get-version.sh 4) echo "#define CANONICAL_VERSION_STRING_4 \"$CANONICALVERSION_4\"" >> ssrf-version.h popd diff --git a/packaging/copr/make-package.sh b/packaging/copr/make-package.sh index 052377284..4f81147ee 100644 --- a/packaging/copr/make-package.sh +++ b/packaging/copr/make-package.sh @@ -26,7 +26,7 @@ cd subsurface git submodule init git submodule update -GITVERSION=$(bash scripts/get-version 4) +GITVERSION=$(bash scripts/get-version.sh 4) GITDATE=$(git log -1 --format="%at" | xargs -I{} date -d @{} +%Y-%m-%d) LIBDCREVISION=$(cd libdivecomputer ; git rev-parse --verify HEAD) FOLDER="subsurface-$GITVERSION" diff --git a/packaging/ios/build.sh b/packaging/ios/build.sh index 0c781bf0a..01bf4bd75 100755 --- a/packaging/ios/build.sh +++ b/packaging/ios/build.sh @@ -77,11 +77,11 @@ if [[ $QT_VERSION = 5.15* ]] ; then fi # set up the Subsurface versions by hand -CANONICALVERSION=$("$SUBSURFACE_SOURCE"/scripts/get-version) +CANONICALVERSION=$("$SUBSURFACE_SOURCE"/scripts/get-version.sh) echo "#define CANONICAL_VERSION_STRING \"$CANONICALVERSION\"" > "$SUBSURFACE_SOURCE"/ssrf-version.h -CANONICALVERSION_4=$("$SUBSURFACE_SOURCE"/scripts/get-version 4) +CANONICALVERSION_4=$("$SUBSURFACE_SOURCE"/scripts/get-version.sh 4) echo "#define CANONICAL_VERSION_STRING_4 \"$CANONICALVERSION_4\"" >> "$SUBSURFACE_SOURCE"/ssrf-version.h -CANONICALVERSION_3=$("$SUBSURFACE_SOURCE"/scripts/get-version 3) +CANONICALVERSION_3=$("$SUBSURFACE_SOURCE"/scripts/get-version.sh 3) echo "#define CANONICAL_VERSION_STRING_3 \"$CANONICALVERSION_3\"" >> "$SUBSURFACE_SOURCE"/ssrf-version.h BUNDLE=org.subsurface-divelog.subsurface-mobile diff --git a/packaging/macosx/make-package.sh b/packaging/macosx/make-package.sh index 5c9f8a18d..8f8b74631 100755 --- a/packaging/macosx/make-package.sh +++ b/packaging/macosx/make-package.sh @@ -11,7 +11,7 @@ DMGCREATE=create-dmg # same git version magic as in the Makefile # for the naming of volume and dmg we want the 3 digits of the full version number -VERSION=$(cd ${DIR}/subsurface; ./scripts/get-version) +VERSION=$(cd ${DIR}/subsurface; ./scripts/get-version.sh) # first build and install Subsurface and then clean up the staging area # make sure we didn't lose the minimum OS version diff --git a/packaging/ubuntu/make-package.sh b/packaging/ubuntu/make-package.sh index 606ad4acd..7f72d2ade 100644 --- a/packaging/ubuntu/make-package.sh +++ b/packaging/ubuntu/make-package.sh @@ -20,7 +20,7 @@ cd subsurface git submodule init git submodule update -GITVERSION=$(bash scripts/get-version 4) +GITVERSION=$(bash scripts/get-version.sh 4) GITDATE=$(git log -1 --format="%at" | xargs -I{} date -d @{} +%Y-%m-%d) LIBDCREVISION=$(cd libdivecomputer ; git rev-parse --verify HEAD) FOLDER="subsurface_$GITVERSION" diff --git a/scripts/check-version b/scripts/check-version.sh similarity index 97% rename from scripts/check-version rename to scripts/check-version.sh index 525d65d22..b845ba587 100755 --- a/scripts/check-version +++ b/scripts/check-version.sh @@ -9,7 +9,7 @@ # To validate relevant files are up to date, you would run the script # from command line before tagging: # -# $ scripts/check-version -cr +# $ scripts/check-version.sh -cr set -eu #set -x diff --git a/scripts/get-version b/scripts/get-version.sh similarity index 76% rename from scripts/get-version rename to scripts/get-version.sh index 2e2271bd2..42c8befc0 100755 --- a/scripts/get-version +++ b/scripts/get-version.sh @@ -4,7 +4,7 @@ # consistently name all builds, regardless of OS or desktop/mobile # # we do need to be able to create three digit (M.m.p) and four digit (M.m.p.c) version strings -# default is VERSION_EXTENSION version - an argument of '4' or '3' gets you a digits only version string +# default is VERSION_EXTENSION version - an argument of '1', '3', or '4' gets you a digits only version string # # we hardcode a base version - this will rarely change # (we actually haven't discussed a situation where it would change...) @@ -16,19 +16,21 @@ croak() { exit 1 } croak_usage() { - croak "Usage: $0 [3|4]" + croak "Usage: $0 [1|3|4]" } if [[ $# -gt 1 ]] ; then croak_usage ; fi if [[ $# -eq 1 ]] ; then - if [[ $1 != "4" && $1 != "3" ]] ; then croak_usage ; fi + if [[ $1 != "1" && $1 != "3" && $1 != "4" ]] ; then croak_usage ; fi DIGITS="$1" fi # figure out where we are in the file system -cd "$(dirname "$0")/../" +pushd "$(dirname "$0")/../" &> /dev/null export SUBSURFACE_SOURCE=$PWD +VERSION_EXTENSION="-" + # add the build number to this as 'patch' component # if we run in an environment where we are given a build number (e.g. CICD builds) # we just grab that - otherwise we have to figure it out on the fly @@ -38,12 +40,12 @@ if [ ! -f latest-subsurface-buildnumber ] ; then # (b) we have the ability to check out another git repo # in situations where either of these isn't true, it's the caller's # responsibility to ensure that the latest-subsurface-buildnumber file exists - if [ ! -d "$SUBSURFACE_SOURCE/nightly-builds" ] ; then + if [ ! -d "nightly-builds" ] ; then git clone https://github.com/subsurface/nightly-builds &> /dev/null || croak "failed to clone nightly-builds repo" fi - cd nightly-builds + pushd nightly-builds &> /dev/null git fetch &> /dev/null - LAST_BUILD_BRANCHES=$(git branch -a --sort=-committerdate --list | grep remotes/origin/branch-for | head -50 | cut -d/ -f3) + LAST_BUILD_BRANCHES=$(git branch -a --sort=-committerdate --list | grep remotes/origin/branch-for | cut -d/ -f3) for LAST_BUILD_BRANCH in $LAST_BUILD_BRANCHES "not-found" ; do LAST_BUILD_SHA=$(cut -d- -f 3 <<< "$LAST_BUILD_BRANCH") git -C "$SUBSURFACE_SOURCE" merge-base --is-ancestor "$LAST_BUILD_SHA" HEAD && break @@ -51,30 +53,33 @@ if [ ! -f latest-subsurface-buildnumber ] ; then [ "not-found" = "$LAST_BUILD_BRANCH" ] && croak "can't find a build number for the current working tree" git checkout "$LAST_BUILD_BRANCH" &> /dev/null || croak "failed to check out $LAST_BUILD_BRANCH in nightly-builds" BUILDNR=$(<./latest-subsurface-buildnumber) - cd "$SUBSURFACE_SOURCE" - VERSION_EXTENSION="-" + popd &> /dev/null VERSION_EXTENSION+=$(git log --pretty="oneline" "${LAST_BUILD_SHA}...HEAD" | wc -l | tr -d '[:space:]') VERSION_EXTENSION+="-" [ "$VERSION_EXTENSION" = "-0-" ] && VERSION_EXTENSION="-" - VERSION_EXTENSION+="local" else - # use the files included with the sources - BUILDNR=$(<"$SUBSURFACE_SOURCE/latest-subsurface-buildnumber") - VERSION_EXTENSION="" - if [ -f "$SUBSURFACE_SOURCE/latest-subsurface-buildnumber-extension" ] ; then - VERSION_EXTENSION="-" - VERSION_EXTENSION+=$(<"$SUBSURFACE_SOURCE/latest-subsurface-buildnumber-extension") - fi + BUILDNR=$(<"latest-subsurface-buildnumber") +fi + +if [ -f "latest-subsurface-buildnumber-extension" ] ; then + VERSION_EXTENSION+=$(<"latest-subsurface-buildnumber-extension") +else + VERSION_EXTENSION+="local" fi COMMITS_SINCE=$(tr -cd "[:digit:]" <<<"$VERSION_EXTENSION") [[ -z $COMMITS_SINCE ]] && COMMITS_SINCE="0" -if [[ $DIGITS == "3" ]] ; then +if [[ $DIGITS == "1" ]] ; then + VERSION="${BUILDNR}" +elif [[ $DIGITS == "3" ]] ; then VERSION="${SUBSURFACE_BASE_VERSION}.${BUILDNR}" elif [[ $DIGITS == "4" ]] ; then VERSION="${SUBSURFACE_BASE_VERSION}.${BUILDNR}.${COMMITS_SINCE}" else VERSION="${SUBSURFACE_BASE_VERSION}.${BUILDNR}${VERSION_EXTENSION}" fi + printf '%s' "$VERSION" + +popd &> /dev/null diff --git a/smtk-import/cmake/Modules/version.cmake b/smtk-import/cmake/Modules/version.cmake index f875cb563..85aee3607 100644 --- a/smtk-import/cmake/Modules/version.cmake +++ b/smtk-import/cmake/Modules/version.cmake @@ -1,13 +1,13 @@ message(STATUS "processing version.cmake") execute_process( - COMMAND bash ${CMAKE_TOP_SRC_DIR}/../scripts/get-version + COMMAND bash ${CMAKE_TOP_SRC_DIR}/../scripts/get-version.sh WORKING_DIRECTORY ${CMAKE_TOP_SRC_DIR} OUTPUT_VARIABLE CANONICAL_VERSION_STRING OUTPUT_STRIP_TRAILING_WHITESPACE ) execute_process( - COMMAND bash ${CMAKE_TOP_SRC_DIR}/../scripts/get-version 4 + COMMAND bash ${CMAKE_TOP_SRC_DIR}/../scripts/get-version.sh 4 WORKING_DIRECTORY ${CMAKE_TOP_SRC_DIR} OUTPUT_VARIABLE CANONICAL_VERSION_STRING_4 OUTPUT_STRIP_TRAILING_WHITESPACE diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml index 3791f55b5..95e94dbf5 100644 --- a/snap/snapcraft.yaml +++ b/snap/snapcraft.yaml @@ -167,7 +167,7 @@ parts: else craftctl set grade=devel fi - craftctl set version=$( scripts/get-version ) + craftctl set version=$( scripts/get-version.sh ) override-build: | mkdir -p ../install-root ln -sf ../../../stage/usr/lib/*/qt5/plugins/geoservices/libqtgeoservices_googlemaps.so \