Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: Automate uploading of assets on releases #1432

Merged
merged 2 commits into from
Jun 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"]'