From 77059ede0f32552bf7333f75604eabf6fb3e9a23 Mon Sep 17 00:00:00 2001 From: Tristan Youngs Date: Tue, 21 Jan 2025 09:41:19 +0000 Subject: [PATCH] build: Better error checking in changeversion, fix missing hash outputs in CI (#2041) --- .github/workflows/_checkout.yml | 3 ++- .github/workflows/_publish.yml | 2 +- .github/workflows/_website.yml | 20 ++++++++++---------- changeversion | 19 +++++++++++-------- 4 files changed, 24 insertions(+), 20 deletions(-) diff --git a/.github/workflows/_checkout.yml b/.github/workflows/_checkout.yml index 996e22c75e..7a9bcf657f 100644 --- a/.github/workflows/_checkout.yml +++ b/.github/workflows/_checkout.yml @@ -101,7 +101,8 @@ jobs: ANTLR_VERSION=$(cat ${{ inputs.conanfile }} | sed -n -e 's%^.*antlr4-cppruntime/%%p') echo "antlrVersion=${ANTLR_VERSION}" >> $GITHUB_OUTPUT - - name: Get nix hash + - name: Get Hashes + id: hashes shell: bash run: | set -ex diff --git a/.github/workflows/_publish.yml b/.github/workflows/_publish.yml index fa45ca47ec..5d808efad0 100644 --- a/.github/workflows/_publish.yml +++ b/.github/workflows/_publish.yml @@ -86,5 +86,5 @@ jobs: shell: bash run: | echo "Publishing to Harbor, tagged as [${{ inputs.publishType }}]..." - apptainer remote login --username ${HARBOR_USER} --password ${HARBOR_SECRET} docker://harbor.stfc.ac.uk + apptainer remote login --username ${{ secrets.HARBOR_USER }} --password ${{ secrets.HARBOR_SECRET }} docker://harbor.stfc.ac.uk apptainer push packages/dissolve-gui-${{ inputs.currentVersion }}.sif oras://harbor.stfc.ac.uk/isis_disordered_materials/dissolve:${{ inputs.publishType }} diff --git a/.github/workflows/_website.yml b/.github/workflows/_website.yml index af606b3fc6..0975cfbe9d 100644 --- a/.github/workflows/_website.yml +++ b/.github/workflows/_website.yml @@ -156,29 +156,29 @@ jobs: if: ${{ inputs.publishType == 'release' }} shell: bash run: | - echo "${SERVER_ID}" > ./serverId - echo "${SERVER_KEY}" > ./serverKey + echo "${{ secrets.SERVER_ID }}" > ./serverId + echo "${{ secrets.SERVER_KEY }}" > ./serverKey chmod 0600 ./serverKey ./serverId - rsync -avz --delete -e "ssh -o UserKnownHostsFile=./serverId -i ./serverKey -p ${SERVER_PORT} -l ${SERVER_USER}" web/public/ ${SERVER_IP}:${SERVER_MAIN_DIR} - rsync -avz --delete --exclude=dev --exclude=legacy -e "ssh -o UserKnownHostsFile=./serverId -i ./serverKey -p ${SERVER_PORT} -l ${SERVER_USER}" web/public-docs/ ${SERVER_IP}:${SERVER_DOCS_DIR} + rsync -avz --delete -e "ssh -o UserKnownHostsFile=./serverId -i ./serverKey -p ${{ secrets.SERVER_PORT }} -l ${{ secrets.SERVER_USER }}" web/public/ ${{ secrets.SERVER_IP }}:${{ secrets.SERVER_MAIN_DIR }} + rsync -avz --delete --exclude=dev --exclude=legacy -e "ssh -o UserKnownHostsFile=./serverId -i ./serverKey -p ${{ secrets.SERVER_PORT }} -l ${{ secrets.SERVER_USER }}" web/public-docs/ ${{ secrets.SERVER_IP }}:${{ secrets.SERVER_DOCS_DIR }} - name: 'SSH Deploy to Server (Legacy) (Docs only)' if: ${{ inputs.publishType == 'legacy' }} shell: bash run: | - echo "${SERVER_ID}" > ./serverId - echo "${SERVER_KEY}" > ./serverKey + echo "${{ secrets.SERVER_ID }}" > ./serverId + echo "${{ secrets.SERVER_KEY }}" > ./serverKey chmod 0600 ./serverKey ./serverId - rsync -avz --delete -e "ssh -o UserKnownHostsFile=./serverId -i ./serverKey -p ${SERVER_PORT} -l ${SERVER_USER}" web/public-docs/ ${SERVER_IP}:${SERVER_DOCS_DIR}/legacy + rsync -avz --delete -e "ssh -o UserKnownHostsFile=./serverId -i ./serverKey -p ${{ secrets.SERVER_PORT }} -l ${{ secrets.SERVER_USER }}" web/public-docs/ ${{ secrets.SERVER_IP }}:${{ secrets.SERVER_DOCS_DIR }}/legacy - name: 'SSH Deploy to Server (Continuous) (Docs only)' if: ${{ inputs.publishType == 'continuous' }} shell: bash run: | - echo "${SERVER_ID}" > ./serverId - echo "${SERVER_KEY}" > ./serverKey + echo "${{ secrets.SERVER_ID }}" > ./serverId + echo "${{ secrets.SERVER_KEY }}" > ./serverKey chmod 0600 ./serverKey ./serverId - rsync -avz --delete -e "ssh -o UserKnownHostsFile=./serverId -i ./serverKey -p ${SERVER_PORT} -l ${SERVER_USER}" web/public-docs/ ${SERVER_IP}:${SERVER_DOCS_DIR}/dev + rsync -avz --delete -e "ssh -o UserKnownHostsFile=./serverId -i ./serverKey -p ${{ secrets.SERVER_PORT }} -l ${{ secrets.SERVER_USER }}" web/public-docs/ ${{ secrets.SERVER_IP }}:${{ secrets.SERVER_DOCS_DIR }}/dev - name: Upload Web Artifacts uses: actions/upload-artifact@v4 diff --git a/changeversion b/changeversion index 54722913f0..011b82cc8e 100755 --- a/changeversion +++ b/changeversion @@ -47,6 +47,11 @@ GetCodeVersion() { MAIN_VERSION=$(grep '#define DISSOLVEVERSION' src/main/version.cpp | sed -e 's/#define DISSOLVEVERSION "\([0-9a-z\.]\+\).*"/\1/g') echo " version.cpp : ${MAIN_VERSION}" + if [[ ! "${MAIN_VERSION}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then + echo "!!! Malformed version (or no version at all) found in version.cpp." + return 1 + fi + # Flake (flake.nix) FLAKE_VERSION=$(grep " version =" flake.nix | sed -e "s/\W*version = \"\(.*\)\";/\1/") echo " flake.nix : ${FLAKE_VERSION}" @@ -83,14 +88,6 @@ GetCodeVersion() { return 0 } -# Windows build files -# sed -i -e "s/#define MyAppVersion \"[0-9\.]*\"/#define MyAppVersion \"$MAJOR.$MINOR.$PATCH\"/g" -e "s/OutputBaseFilename=Dissolve-GUI-[0-9\.]*-Win64/OutputBaseFilename=Dissolve-GUI-$MAJOR.$MINOR.$PATCH-Win64/g" ci/windows/dissolve-gui.iss -# echo -n " dissolve-gui.iss (Program Version) : " -# grep 'define MyAppVersion' ci/windows/dissolve-gui.iss | sed -e 's/#define MyAppVersion \"\([0-9\.]*\)\"/\1/g' -# echo -n " dissolve-gui.iss (Output Filename) : " -# grep 'OutputBaseFilename' ci/windows/dissolve-gui.iss | sed -e 's/OutputBaseFilename=Dissolve-GUI-\([0-9\.]*\)-Win64/\1/g' - - # Set web release version and date SetWebReleaseInfo() { # Must have new version string as argument @@ -117,6 +114,12 @@ GetWebReleaseInfo() { echo " main.toml (Version) : ${WEB_VERSION}" echo " main.toml (Date) : ${WEB_DATE}" + # Did we get a sensible version out of the file? + if [[ ! "${WEB_VERSION}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then + echo "!!! Malformed version (or no version at all) found in main.toml." + return 1 + fi + # Check Version? if [ $# == 1 ] && [ ${WEB_VERSION} != "$1" ] then