Zipping Git-LFS binaries in GitHub Actions and adding them as asset to a release?

Viewed 464

Long-story short part of my GitHub repository are two folders containing a mix of text (.tbx) and binaries (.png) which I would like to zip and add as assets to a release using workflows. The files inside the zip get corrupted and that's visible from a ridiculously small size - expected zip size around 70mb, but is less than 1mb.

I assume it has to do with Git-LFS, but being new to Git-LFS and GitHub Actions (never used it before, never had to) is there a way to zip these files/folders or should I give up on Git-LFS completely?

Here is one of many iterations of my GitHub Actions workflow code:

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
      - name: Build project # This would actually build your project, using zip for an example artifact
        run: |
          zip -rn .png 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

Here is a snippet of the zipping with the above code, running without -n turns 'stored' into 'deflate'

1 Answers

I have fixed it by adding the following

        with:
          lfs: 'true'  

to the Checkout code step, so now it looks like this:

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 Resources Resources
      - 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: ./Resources.zip
          asset_name: Resources.zip
          asset_content_type: application/zip
Related