Skip to content

Commit

Permalink
Merge pull request #1432 from rockstorm101/automate-ci-upload
Browse files Browse the repository at this point in the history
Automate uploading of assets on releases and simplify file naming for macOS builds.

Closes #1427
  • Loading branch information
rockstorm101 committed Jun 28, 2024
2 parents 0af3755 + 98838a0 commit ef8b846
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 8 deletions.
17 changes: 11 additions & 6 deletions .github/workflows/buildpackage-mac.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
pull_request:
release:
types:
- created
- published

jobs:
build:
Expand Down Expand Up @@ -56,20 +56,25 @@ jobs:
- name: Configuration for releases
if: ${{ github.event_name == 'release' }}
run: |
echo "EXE_NAME=${{ github.ref_name }}" >> $GITHUB_ENV
echo "EXE_NAME=${{ github.ref_name }}_macos_${{ matrix.architecture }}" >> $GITHUB_ENV
- name: Configuration for pushes
if: ${{ github.event_name == 'push' }}
run: |
echo "EXE_NAME=printrun-nightly" >> $GITHUB_ENV
echo "EXE_NAME=printrun-nightly_${{ matrix.os }}_${{ matrix.architecture }}_py${{ matrix.python-version }}" >> $GITHUB_ENV
- name: Configuration for pull requests
if: ${{ github.event_name != 'release' && github.event_name != 'push' }}
if: ${{ github.event_name == 'pull_request' }}
run: |
echo "EXE_NAME=printrun-test" >> $GITHUB_ENV
echo "EXE_NAME=printrun-test_${{ matrix.os }}_${{ matrix.architecture }}_py${{ matrix.python-version }}" >> $GITHUB_ENV
- name: Upload artifacts for inspection
uses: actions/upload-artifact@v4
with:
name: ${{ env.EXE_NAME }}_${{ matrix.os }}_${{ matrix.architecture }}_py${{ matrix.python-version }}
name: ${{ env.EXE_NAME }}
path: dist/Pronterface-app.zip

upload_release_assets:
needs: [build]
if: github.event_name == 'release' && github.event.action == 'published'
uses: kliment/Printrun/.github/workflows/upload-assets.yml@master
9 changes: 7 additions & 2 deletions .github/workflows/buildpackage-win.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
pull_request:
release:
types:
- created
- published

jobs:
build:
Expand Down Expand Up @@ -76,7 +76,7 @@ jobs:
"EXE_NAME=printrun-nightly" >> $env:GITHUB_ENV
- name: Configuration for pull requests
if: ${{ github.event_name != 'release' && github.event_name != 'push' }}
if: ${{ github.event_name == 'pull_request' }}
run: |
"EXE_NAME=printrun-test" >> $env:GITHUB_ENV
Expand All @@ -88,3 +88,8 @@ jobs:
dist/Pronterface.exe
dist/Pronsole.exe
dist/locale
upload_release_assets:
needs: [build]
if: github.event_name == 'release' && github.event.action == 'published'
uses: kliment/Printrun/.github/workflows/upload-assets.yml@master
40 changes: 40 additions & 0 deletions .github/workflows/upload-assets.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Upload Assets to Releases

on:
workflow_call:

jobs:
upload_release_assets:
runs-on: ubuntu-latest
permissions:
contents: write
checks: write
actions: read
issues: read
packages: write
pull-requests: read
repository-projects: read
statuses: read
steps:
- name: Get artifacts
uses: actions/download-artifact@v4
with:
pattern: printrun-*
path: upload
merge-multiple: false

- name: Zip artifacts for uploading
run: |
cd upload || { echo "Failed to cd into 'upload'"; exit 1; }
for i in *; do
cd "$i" || { echo "Failed to cd into '$i'"; exit 1; }
zip -r "../$i.zip" ./*
cd ..
done
- name: Upload assets
uses: alexellis/[email protected]
env:
GITHUB_TOKEN: ${{ github.token }}
with:
asset_paths: '["upload/*.zip"]'

0 comments on commit ef8b846

Please sign in to comment.