Refactor GitHub actions workflow and improve environment handling

Changed the Github actions workflow by renaming "default-values" to "default_values" across multiple files. In addition,
improved environment summary handling by reading its content if the file exists, and finally, appending certain
variables to it. This makes the workflow more consistent and better handles the environment summary.
This commit is contained in:
Jelle Spijker 2023-11-01 11:34:44 +01:00
parent 8f35c606d1
commit 2a81d57236
No known key found for this signature in database
GPG Key ID: 034D1C0527888B65

View File

@ -43,7 +43,7 @@ env:
LATEST_RELEASE_SCHEDULE_HOUR: 4 LATEST_RELEASE_SCHEDULE_HOUR: 4
jobs: jobs:
default-values: default_values:
runs-on: ubuntu-latest runs-on: ubuntu-latest
outputs: outputs:
cura_conan_version: ${{ steps.default.outputs.cura_conan_version }} cura_conan_version: ${{ steps.default.outputs.cura_conan_version }}
@ -76,11 +76,22 @@ jobs:
f.writelines(f"cura_conan_version={cura_conan_version}\n") f.writelines(f"cura_conan_version={cura_conan_version}\n")
f.writelines(f"release_tag={release_tag}\n") f.writelines(f"release_tag={release_tag}\n")
summary_env = os.environ["GITHUB_STEP_SUMMARY"]
content = ""
if os.path.exists(summary_env):
with open(summary_env, "r") as f:
content = f.read()
with open(summary_env, "w") as f:
f.write(content)
f.writelines(f"# cura_conan_version = {cura_conan_version}\n")
f.writelines(f"# release_tag = {release_tag}\n")
windows-installer: windows-installer:
uses: ./.github/workflows/windows.yml uses: ./.github/workflows/windows.yml
needs: [ default-values ] needs: [ default_values ]
with: with:
cura_conan_version: ${{ needs.default-values.outputs.cura_conan_version }} cura_conan_version: ${{ needs.default_values.outputs.cura_conan_version }}
conan_args: ${{ github.event.inputs.conan_args }} conan_args: ${{ github.event.inputs.conan_args }}
enterprise: ${{ github.event.inputs.enterprise == 'true' }} enterprise: ${{ github.event.inputs.enterprise == 'true' }}
staging: ${{ github.event.inputs.staging == 'true' }} staging: ${{ github.event.inputs.staging == 'true' }}
@ -90,9 +101,9 @@ jobs:
linux-installer: linux-installer:
uses: ./.github/workflows/linux.yml uses: ./.github/workflows/linux.yml
needs: [ default-values ] needs: [ default_values ]
with: with:
cura_conan_version: ${{ needs.default-values.outputs.cura_conan_version }} cura_conan_version: ${{ needs.default_values.outputs.cura_conan_version }}
conan_args: ${{ github.event.inputs.conan_args }} conan_args: ${{ github.event.inputs.conan_args }}
enterprise: ${{ github.event.inputs.enterprise == 'true' }} enterprise: ${{ github.event.inputs.enterprise == 'true' }}
staging: ${{ github.event.inputs.staging == 'true' }} staging: ${{ github.event.inputs.staging == 'true' }}
@ -102,9 +113,9 @@ jobs:
macos-installer: macos-installer:
uses: ./.github/workflows/macos.yml uses: ./.github/workflows/macos.yml
needs: [ default-values ] needs: [ default_values ]
with: with:
cura_conan_version: ${{ needs.default-values.outputs.cura_conan_version }} cura_conan_version: ${{ needs.default_values.outputs.cura_conan_version }}
conan_args: ${{ github.event.inputs.conan_args }} conan_args: ${{ github.event.inputs.conan_args }}
enterprise: ${{ github.event.inputs.enterprise == 'true' }} enterprise: ${{ github.event.inputs.enterprise == 'true' }}
staging: ${{ github.event.inputs.staging == 'true' }} staging: ${{ github.event.inputs.staging == 'true' }}
@ -114,9 +125,9 @@ jobs:
macos-arm-installer: macos-arm-installer:
uses: ./.github/workflows/macos.yml uses: ./.github/workflows/macos.yml
needs: [ default-values ] needs: [ default_values ]
with: with:
cura_conan_version: ${{ needs.default-values.outputs.cura_conan_version }} cura_conan_version: ${{ needs.default_values.outputs.cura_conan_version }}
conan_args: ${{ github.event.inputs.conan_args }} conan_args: ${{ github.event.inputs.conan_args }}
enterprise: ${{ github.event.inputs.enterprise == 'true' }} enterprise: ${{ github.event.inputs.enterprise == 'true' }}
staging: ${{ github.event.inputs.staging == 'true' }} staging: ${{ github.event.inputs.staging == 'true' }}
@ -128,7 +139,7 @@ jobs:
update-nightly-release: update-nightly-release:
if: ${{ inputs.nightly || github.event_name == 'schedule' }} if: ${{ inputs.nightly || github.event_name == 'schedule' }}
runs-on: ubuntu-latest runs-on: ubuntu-latest
needs: [ windows-installer, linux-installer, macos-installer, macos-arm-installer ] needs: [ default_values, windows-installer, linux-installer, macos-installer, macos-arm-installer ]
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v3 uses: actions/checkout@v3
@ -196,8 +207,8 @@ jobs:
- name: Update nightly release for Linux - name: Update nightly release for Linux
run: | run: |
gh release upload ${{ needs.default-values.outputs.release_tag }} installers/${{ steps.filename.outputs.NIGHTLY_NAME }}-linux-X64.AppImage --clobber gh release upload ${{ needs.default_values.outputs.release_tag }} installers/${{ steps.filename.outputs.NIGHTLY_NAME }}-linux-X64.AppImage --clobber
gh release upload ${{ needs.default-values.outputs.release_tag }} installers/${{ steps.filename.outputs.NIGHTLY_NAME }}-linux-X64.AppImage.asc --clobber gh release upload ${{ needs.default_values.outputs.release_tag }} installers/${{ steps.filename.outputs.NIGHTLY_NAME }}-linux-X64.AppImage.asc --clobber
env: env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@ -220,8 +231,8 @@ jobs:
- name: Update nightly release for Windows - name: Update nightly release for Windows
run: | run: |
gh release upload ${{ needs.default-values.outputs.release_tag }} installers/${{ steps.filename.outputs.NIGHTLY_NAME }}-win64-X64.msi --clobber gh release upload ${{ needs.default_values.outputs.release_tag }} installers/${{ steps.filename.outputs.NIGHTLY_NAME }}-win64-X64.msi --clobber
gh release upload ${{ needs.default-values.outputs.release_tag }} installers/${{ steps.filename.outputs.NIGHTLY_NAME }}-win64-X64.exe --clobber gh release upload ${{ needs.default_values.outputs.release_tag }} installers/${{ steps.filename.outputs.NIGHTLY_NAME }}-win64-X64.exe --clobber
env: env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@ -244,8 +255,8 @@ jobs:
- name: Update nightly release for MacOS (X64) - name: Update nightly release for MacOS (X64)
run: | run: |
gh release upload ${{ needs.default-values.outputs.release_tag }} installers/${{ steps.filename.outputs.NIGHTLY_NAME }}-macos-X64.dmg --clobber gh release upload ${{ needs.default_values.outputs.release_tag }} installers/${{ steps.filename.outputs.NIGHTLY_NAME }}-macos-X64.dmg --clobber
gh release upload ${{ needs.default-values.outputs.release_tag }} installers/${{ steps.filename.outputs.NIGHTLY_NAME }}-macos-X64.pkg --clobber gh release upload ${{ needs.default_values.outputs.release_tag }} installers/${{ steps.filename.outputs.NIGHTLY_NAME }}-macos-X64.pkg --clobber
env: env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@ -268,8 +279,8 @@ jobs:
- name: Update nightly release for MacOS (ARM-64) - name: Update nightly release for MacOS (ARM-64)
run: | run: |
gh release upload ${{ needs.default-values.outputs.release_tag }} installers/${{ steps.filename.outputs.NIGHTLY_NAME }}-macos-ARM64.dmg --clobber gh release upload ${{ needs.default_values.outputs.release_tag }} installers/${{ steps.filename.outputs.NIGHTLY_NAME }}-macos-ARM64.dmg --clobber
gh release upload ${{ needs.default-values.outputs.release_tag }} installers/${{ steps.filename.outputs.NIGHTLY_NAME }}-macos-ARM64.pkg --clobber gh release upload ${{ needs.default_values.outputs.release_tag }} installers/${{ steps.filename.outputs.NIGHTLY_NAME }}-macos-ARM64.pkg --clobber
env: env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@ -282,17 +293,17 @@ jobs:
with open(".github/workflows/release-notes.md.jinja", "r") as f: with open(".github/workflows/release-notes.md.jinja", "r") as f:
release_notes = Template(f.read()) release_notes = Template(f.read())
current_nightly_beta = "${{ needs.default-values.outputs.release_tag }}".split("nightly-")[-1] current_nightly_beta = "${{ needs.default_values.outputs.release_tag }}".split("nightly-")[-1]
with open("release-notes.md", "w") as f: with open("release-notes.md", "w") as f:
f.write(release_notes.render( f.write(release_notes.render(
timestamp=${{ steps.filename.outputs.NIGHTLY_TIME }}, timestamp=${{ steps.filename.outputs.NIGHTLY_TIME }},
branch="" if ${{ needs.default-values.outputs.release_tag == 'nightly' }} else current_nightly_beta, branch="" if ${{ needs.default_values.outputs.release_tag == 'nightly' }} else current_nightly_beta,
branch_specific="" if os.getenv("GITHUB_REF") == "refs/heads/main" else f"?branch={current_nightly_beta}", branch_specific="" if os.getenv("GITHUB_REF") == "refs/heads/main" else f"?branch={current_nightly_beta}",
)) ))
- name: Update nightly release description (with date) - name: Update nightly release description (with date)
if: always() if: always()
run: | run: |
gh release edit ${{ needs.default-values.outputs.release_tag }} --title "${{ steps.filename.outputs.NIGHTLY_NAME }}" --notes-file release-notes.md gh release edit ${{ needs.default_values.outputs.release_tag }} --title "${{ steps.filename.outputs.NIGHTLY_NAME }}" --notes-file release-notes.md
env: env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}