From fe4da06e13a96001d9fd5320f6c547ce4abe5de2 Mon Sep 17 00:00:00 2001 From: Tristan Youngs Date: Tue, 26 Nov 2024 12:51:52 +0000 Subject: [PATCH] build: Update release publishing workflow (#2018) --- .github/workflows/continuous.yml | 24 ++++++++++++++++-- .github/workflows/publish/action.yml | 37 +++++++++++----------------- .github/workflows/release.yml | 24 ++++++++++++++++-- .github/workflows/web.yml | 17 ++----------- .github/workflows/website/action.yml | 32 +++++++++++------------- 5 files changed, 75 insertions(+), 59 deletions(-) diff --git a/.github/workflows/continuous.yml b/.github/workflows/continuous.yml index f8c76cd52f..bddc5ad136 100644 --- a/.github/workflows/continuous.yml +++ b/.github/workflows/continuous.yml @@ -92,8 +92,28 @@ jobs: - name: Publish uses: "./.github/workflows/publish" with: - isRelease: false - publish: true + publishType: 'continuous' env: HARBOR_USER: ${{ secrets.HARBOR_USER }} HARBOR_SECRET: ${{ secrets.HARBOR_SECRET }} + + Web: + needs: [ Package, BuildLinux ] + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Setup + uses: "./.github/workflows/setup" + - name: Build Website + uses: "./.github/workflows/website" + with: + publishType: 'continuous' + env: + SERVER_ID: ${{ secrets.SERVER_ID }} + SERVER_KEY: ${{ secrets.SERVER_KEY }} + SERVER_USER: ${{ secrets.SERVER_USER }} + SERVER_IP: ${{ secrets.SERVER_IP }} + SERVER_DOCS_DIR: ${{ secrets.SERVER_DOCS_DIR }} + SERVER_MAIN_DIR: ${{ secrets.SERVER_MAIN_DIR }} + SERVER_PORT: ${{ secrets.SERVER_PORT }} diff --git a/.github/workflows/publish/action.yml b/.github/workflows/publish/action.yml index 6cc7a57c76..50c954f0b0 100644 --- a/.github/workflows/publish/action.yml +++ b/.github/workflows/publish/action.yml @@ -2,12 +2,14 @@ name: Publish description: Publish artifacts online inputs: - isRelease: - type: boolean - default: false - publish: - type: boolean - default: true + publishType: + type: choice + default: 'none' + options: + - none + - continuous + - release + - legacy runs: using: "composite" @@ -39,16 +41,15 @@ runs: ./package-examples -v ${{ env.dissolveVersion }} - name: Publish on GitHub (Release) - if: ${{ inputs.publish == 'true' && inputs.isRelease == 'true' }} + if: ${{ inputs.publishType == 'release' }} shell: bash run: | - echo "Release tag will be: ${{ env.dissolveVersion }}" - echo "Release name will be: ${{ env.dissolveVersion }}" + echo "Release tag/name will be: ${{ env.dissolveVersion }}" export GITHUB_TOKEN=${{ github.token }} ./update-release -r disorderedmaterials/dissolve -t ${{ env.dissolveVersion }} -n "${{ env.dissolveVersion }}" -f ReleaseNotes.md packages/* examples/*.zip examples/*.tar.gz - name: Publish on GitHub (Continuous) - if: ${{ inputs.publish == 'true' && inputs.isRelease == 'false' }} + if: ${{ inputs.publishType == 'continuous' }} shell: bash run: | echo "Release tag will be: continuous" @@ -56,18 +57,10 @@ runs: export GITHUB_TOKEN=${{ github.token }} ./update-release -r disorderedmaterials/dissolve -t continuous -p -e -u -n "Continuous (${{ env.dissolveVersion }} @ ${{ env.dissolveShortHash }})" -b "Continuous release from \`develop\` branch @ ${{ env.dissolveShortHash }}. Built $(date)." packages/* - - name: Publish on Harbor (Release) - if: ${{ inputs.publish == 'true' && inputs.isRelease == 'true' }} + - name: Publish on Harbor + if: ${{ inputs.publishType != 'none' }} shell: bash run: | - echo "Release tag will be: latest" + echo "Publishing to Harbor, tagged as [${{ inputs.publishType }}]..." apptainer remote login --username ${HARBOR_USER} --password ${HARBOR_SECRET} docker://harbor.stfc.ac.uk - apptainer push packages/dissolve-gui-${{ env.dissolveVersion }}.sif oras://harbor.stfc.ac.uk/isis_disordered_materials/dissolve:latest - - - name: Publish on Harbor (Continuous) - if: ${{ inputs.publish == 'true' && inputs.isRelease == 'false' }} - shell: bash - run: | - echo "Release tag will be: continuous" - apptainer remote login --username ${HARBOR_USER} --password ${HARBOR_SECRET} docker://harbor.stfc.ac.uk - apptainer push packages/dissolve-gui-${{ env.dissolveVersion }}.sif oras://harbor.stfc.ac.uk/isis_disordered_materials/dissolve:continuous + apptainer push packages/dissolve-gui-${{ env.dissolveVersion }}.sif oras://harbor.stfc.ac.uk/isis_disordered_materials/dissolve:${{ inputs.publishType }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index f9070ab140..b681b2896b 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -90,8 +90,7 @@ jobs: - name: Publish uses: "./.github/workflows/publish" with: - isRelease: true - publish: ${{ ! endsWith(github.ref, 'pre') }} + publishType: 'release' env: HARBOR_USER: ${{ secrets.HARBOR_USER }} HARBOR_SECRET: ${{ secrets.HARBOR_SECRET }} @@ -100,3 +99,24 @@ jobs: with: createPR: ${{ ! endsWith(github.ref, 'pre') }} releaseVersion: ${{ env.dissolveVersion }} + + Web: + needs: [ Package, BuildLinux ] + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Setup + uses: "./.github/workflows/setup" + - name: Build Website + uses: "./.github/workflows/website" + with: + publishType: 'release' + env: + SERVER_ID: ${{ secrets.SERVER_ID }} + SERVER_KEY: ${{ secrets.SERVER_KEY }} + SERVER_USER: ${{ secrets.SERVER_USER }} + SERVER_IP: ${{ secrets.SERVER_IP }} + SERVER_DOCS_DIR: ${{ secrets.SERVER_DOCS_DIR }} + SERVER_MAIN_DIR: ${{ secrets.SERVER_MAIN_DIR }} + SERVER_PORT: ${{ secrets.SERVER_PORT }} diff --git a/.github/workflows/web.yml b/.github/workflows/web.yml index d64a63500f..8115db070c 100644 --- a/.github/workflows/web.yml +++ b/.github/workflows/web.yml @@ -1,4 +1,4 @@ -name: Website Build +name: Test Website Build on: pull_request: @@ -28,17 +28,4 @@ jobs: - name: Build Website uses: "./.github/workflows/website" with: - isDevelopment: ${{ github.ref_name == 'develop' || github.event_name == 'pull_request' }} - isRelease: ${{ startsWith(github.ref_name, 'release') }} - isLegacy: false - deploy: ${{ github.ref_name == 'develop' || (startsWith(github.ref_name, 'release') && ! endsWith(github.ref_name, 'pre')) }} - env: - HARBOR_USER: ${{ secrets.HARBOR_USER }} - HARBOR_SECRET: ${{ secrets.HARBOR_SECRET }} - SERVER_ID: ${{ secrets.SERVER_ID }} - SERVER_KEY: ${{ secrets.SERVER_KEY }} - SERVER_USER: ${{ secrets.SERVER_USER }} - SERVER_IP: ${{ secrets.SERVER_IP }} - SERVER_DOCS_DIR: ${{ secrets.SERVER_DOCS_DIR }} - SERVER_MAIN_DIR: ${{ secrets.SERVER_MAIN_DIR }} - SERVER_PORT: ${{ secrets.SERVER_PORT }} + publishType: 'none' diff --git a/.github/workflows/website/action.yml b/.github/workflows/website/action.yml index e7a3777a1c..3b59f40d9f 100644 --- a/.github/workflows/website/action.yml +++ b/.github/workflows/website/action.yml @@ -2,18 +2,14 @@ name: Website description: Build and publish website inputs: - isRelease: - type: boolean - default: false - isDevelopment: - type: boolean - default: false - isLegacy: - type: boolean - default: false - deploy: - type: boolean - default: false + publishType: + type: choice + default: 'none' + options: + - none + - continuous + - release + - legacy pdfExamples: type: boolean default: false @@ -27,7 +23,7 @@ runs: run: sed -i "s/MAJOR.MINOR/${{ env.dissolveMajorVersion }}.${{ env.dissolveMinorVersion }}/g" web/docs.toml - name: 'Apply Main Release Styling' - if: ${{ inputs.isRelease == 'true' && inputs.isLegacy == 'false' }} + if: ${{ inputs.publishType == 'release' }} shell: bash run: | # Set version and tip visibility in docs index @@ -36,7 +32,7 @@ runs: head -n 10 web/docs/_index.md - name: 'Apply Development Release Styling' - if: ${{ inputs.isDevelopment == 'true' }} + if: ${{ inputs.publishType == 'continuous' }} shell: bash run: | # Set version and tip visibility in docs index @@ -53,7 +49,7 @@ runs: grep navbar-background-color web/assets/scss/_content.scss - name: 'Apply Legacy Release Styling' - if: ${{ inputs.isLegacy == 'true' }} + if: ${{ inputs.publishType == 'legacy' }} shell: bash run: | # Set version and tip visibility in docs index @@ -131,7 +127,7 @@ runs: done - name: 'SSH Deploy to Server (Release) (Docs only)' - if: ${{ inputs.deploy == 'true' && inputs.isRelease == 'true' && inputs.isLegacy == 'false' }} + if: ${{ inputs.publishType == 'release' }} shell: bash run: | echo "${SERVER_ID}" > ./serverId @@ -140,7 +136,7 @@ runs: 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} - name: 'SSH Deploy to Server (Legacy) (Docs only)' - if: ${{ inputs.deploy == 'true' && inputs.isLegacy == 'true' }} + if: ${{ inputs.publishType == 'legacy' }} shell: bash run: | echo "${SERVER_ID}" > ./serverId @@ -149,7 +145,7 @@ runs: 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 - name: 'SSH Deploy to Server (Development)' - if: ${{ inputs.deploy == 'true' && inputs.isDevelopment == 'true' }} + if: ${{ inputs.publishType == 'continuous' }} shell: bash run: | echo "${SERVER_ID}" > ./serverId