actions / upload-release-asset

An Action to upload a release asset via the GitHub Release API
MIT License
683 stars 187 forks source link

Is it possible to zip and attach multiple assets to a single release? #71

Closed xuvvy closed 3 years ago

xuvvy commented 3 years ago

As the title suggests I am wondering if it is possible and how it would be possible to zip and attach multiple assets to a single release?

Here is example of code similar to what I'm trying to use:

on:
  workflow_dispatch:

name: Upload Release Asset

jobs:
  build:
    name: Upload Release Asset
    runs-on: ubuntu-latest
    steps:
      - name: Checkout code
        uses: actions/checkout@v2
        with:
          lfs: 'true'          
      - name: Build project # This would actually build your project, using zip for an example artifact
        run: |
          zip -r Buildings Resources/Buildings/
      - name: Create Release
        id: create_release
        uses: actions/create-release@v1
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        with:
          tag_name: ${{ github.ref }}
          release_name: Release ${{ github.ref }}
          draft: true
          prerelease: false
      - name: Upload Release Asset
        id: upload-release-asset 
        uses: actions/upload-release-asset@v1
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        with:
          upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps 
          asset_path: ./Buildings.zip
          asset_name: Buildings.zip
          asset_content_type: application/zip
xuvvy commented 3 years ago

Ah, it was as simple as adding a step for each zipped file or folder!

Like this:

on:
  workflow_dispatch:

name: Release with Assets

jobs:
  build:
    name: Release with Assets
    runs-on: ubuntu-latest
    steps:
      - name: Checkout code
        uses: actions/checkout@v2
        with:
          lfs: 'true'          
      - name: Build project # This would actually build your project, using zip for an example artifact
        run: |
          zip -r Buildings Assets/Asset01
          zip -r Palettes Assets/Asset02
          zip -r Tiles Assets/Asset03
          zip -r Tools Assets/Asset04
      - name: Create Release
        id: create_release
        uses: actions/create-release@v1
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        with:
          tag_name: v
          release_name: Release Draft
          draft: true
          prerelease: false
      - name: Upload Release Asset 01
        id: upload-release-asset-01
        uses: actions/upload-release-asset@v1.0.2
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        with:
          upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing its ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps 
          asset_path: ./Asset01.zip
          asset_name: Asset01.zip
          asset_content_type: application/zip
      - name: Upload Release Asset 02
        id: upload-release-asset-02 
        uses: actions/upload-release-asset@v1.0.2
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        with:
          upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing its ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps 
          asset_path: ./Asset02.zip
          asset_name: Asset02.zip
          asset_content_type: application/zip
      - name: Upload Release Asset 03
        id: upload-release-asset-03
        uses: actions/upload-release-asset@v1.0.2
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        with:
          upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing its ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps 
          asset_path: ./Asset03.zip
          asset_name: Asset03.zip
          asset_content_type: application/zip
      - name: Upload Release Asset 04
        id: upload-release-asset-04 
        uses: actions/upload-release-asset@v1.0.2
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        with:
          upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing its ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps 
          asset_path: ./Asset04.zip
          asset_name: Asset04.zip
          asset_content_type: application/zip