Skip to content

Commit

Permalink
Refactor GitHub actions workflow and improve environment handling
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jellespijker committed Nov 1, 2023
1 parent 8f35c60 commit 2a81d57
Showing 1 changed file with 32 additions and 21 deletions.
53 changes: 32 additions & 21 deletions .github/workflows/installers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ env:
LATEST_RELEASE_SCHEDULE_HOUR: 4

jobs:
default-values:
default_values:
runs-on: ubuntu-latest
outputs:
cura_conan_version: ${{ steps.default.outputs.cura_conan_version }}
Expand Down Expand Up @@ -76,11 +76,22 @@ jobs:
f.writelines(f"cura_conan_version={cura_conan_version}\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:
uses: ./.github/workflows/windows.yml
needs: [ default-values ]
needs: [ default_values ]
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 }}
enterprise: ${{ github.event.inputs.enterprise == 'true' }}
staging: ${{ github.event.inputs.staging == 'true' }}
Expand All @@ -90,9 +101,9 @@ jobs:

linux-installer:
uses: ./.github/workflows/linux.yml
needs: [ default-values ]
needs: [ default_values ]
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 }}
enterprise: ${{ github.event.inputs.enterprise == 'true' }}
staging: ${{ github.event.inputs.staging == 'true' }}
Expand All @@ -102,9 +113,9 @@ jobs:

macos-installer:
uses: ./.github/workflows/macos.yml
needs: [ default-values ]
needs: [ default_values ]
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 }}
enterprise: ${{ github.event.inputs.enterprise == 'true' }}
staging: ${{ github.event.inputs.staging == 'true' }}
Expand All @@ -114,9 +125,9 @@ jobs:

macos-arm-installer:
uses: ./.github/workflows/macos.yml
needs: [ default-values ]
needs: [ default_values ]
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 }}
enterprise: ${{ github.event.inputs.enterprise == 'true' }}
staging: ${{ github.event.inputs.staging == 'true' }}
Expand All @@ -128,7 +139,7 @@ jobs:
update-nightly-release:
if: ${{ inputs.nightly || github.event_name == 'schedule' }}
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:
- name: Checkout
uses: actions/checkout@v3
Expand Down Expand Up @@ -196,8 +207,8 @@ jobs:
- name: Update nightly release for Linux
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.asc --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
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Expand All @@ -220,8 +231,8 @@ jobs:
- name: Update nightly release for Windows
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.exe --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
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Expand All @@ -244,8 +255,8 @@ jobs:
- name: Update nightly release for MacOS (X64)
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.pkg --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
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Expand All @@ -268,8 +279,8 @@ jobs:
- name: Update nightly release for MacOS (ARM-64)
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.pkg --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
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Expand All @@ -282,17 +293,17 @@ jobs:
with open(".github/workflows/release-notes.md.jinja", "r") as f:
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:
f.write(release_notes.render(
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}",
))
- name: Update nightly release description (with date)
if: always()
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:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 comments on commit 2a81d57

Please sign in to comment.