Github release a specific folder

12k Views Asked by At

I have a repository that has a bunch of folders, but I want to create releases for just one of those folders.

Simpler story, it's for a gaming server, and I just want to create releases for the client, as the way of offering downloads of the client to players.

5

There are 5 best solutions below

6
On

If the client/ folder content can be re-built from the rest of the project, ideally, it should not be versioned.

Versioned or not, you can build your release artifact (here, a zip of the client/ folder) and publish it to your repo as a GitHub release.
See "Creating Releases".

It supposes you make a tag first on your repo, in order to associate that zip file to a precise version of said repo.

0
On

When a release is published, the automatically generated Source Code .zip and .tar.gz files include all files in the branch you choose here: Selecting git branch for release
(source: github.com)

Therefore, I answered the OP's question this way:

1. Use a branch containing only the release contents

  1. Create a new branch with the contents of your current branch and check it out (e.g. git checkout -b rel)
  2. Delete all non-release files and folders (don't worry, you're only deleting them from the new branch, confirm you are on the right one using git branch)
  3. Move release folder contents to the root folder and delete the empty folder
  4. Stage and commit all changes (e.g. git add . + git commit -a -m "v1 release"
  5. (optional: do not do this if you prefer using the Github interface for writing the release details) Create a release version tag (e.g. `git tag v1.0.0 -m "initial release")
  6. Push this new branch (e.g. git push --set-upstream origin rel)

2. Add an executable/installer to the release

  1. Browse and log into your account and head to https://github.com/USER-NAME/PROJECT-NAME/releases
  2. Click the button for a new release and fill in the release details, choosing the branch you created above
  3. Since GitHub limits uploads of files larger than 50MB (unless you use Git LFS), your runnables (e.g. .exe or .apk) can be added and uploaded into the release itself before publishing it via drag-and-drop:

Dragging files to release

The release will be automatically saved as draft and, only upon publishing, the Source Code archive files will be generated (without the runnables you added above).

P.S.: Images and steps for creating and editing a release available on Managing Releases Gihub Docs page.

0
On

A release is always of an executable file - for ex. *.exe, *.tar.gz, *.zip, *.apk, etc. - it could be a list of such files but I haven't come across any folder being released. However, you can release all files that are within a folder.

To release your files in that folder, you can use a action like this one: https://github.com/marketplace/actions/upload-files-to-a-github-release. Go to the "Example with file_glob:" section which has a nice example. I've copy-pasted the code snippet here but I highly recommend you to visit the link for a deeper dive.

name: Publish
on:
  push:
    tags:
      - '*'

jobs:
  build:
    name: Publish binaries
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v3
    - name: Build
      run: cargo build --release

    - name: Upload binaries to release
      uses: svenstaro/upload-release-action@v2
      with:
        repo_token: ${{ secrets.GITHUB_TOKEN }}
        file: target/release/my/* # the folder which has all the files that you want to release
        tag: ${{ github.ref }}
        overwrite: true
        file_glob: true

Good Luck...

1
On

Github official document on Releases

VonC shared link

=> As VonC shared the link: from it we glean that to include only one file in your release; you must make a new branch with that specific file_

=> Mention new branch in the release's Target field_

0
On

To release a given folder that is in a given repository (assumes Windows OS, step 7 may vary otherwise), you can use this procedure:

  1. Go to the Releases page for the repository (e.g., https://github.com/<organization>/<repository>/releases).

  2. Click the button to create a new release.

  3. In the “Choose a tag” drop-down, enter a version number in this format: v1.2.3 (it may be helpful to read about semantic versioning using the link on the right of the page).

  4. Select the version number you just created (i.e., ensure it appears as selected in the drop-down).

  5. Release title is optional, skip over it or enter something brief and meaningful.

  6. In the “Describe this release” field, add the install steps and any other info that would be relevant to the consumer(s) of your release.

  7. Create a ZIP of your release package as follows (zipping is necessary because folder uploads are not possible, only files):

    a. Create your package locally by organizing the source files into folders the way they would be copied to the target device. For example, if the target app has a bin folder and you’re just deploying bin\foo.dll and want to retain this folder structure on the target, create a local (temporary) bin folder that includes only that DLL. This folder will ultimately become your package. Do not include files/folders that should not be copied to the target.

    b. Right-click the folder(s) you created (bin in the example above) and select “Send to” > “Compressed (zipped) folder”.

    c. Give it a suitable name (e.g., MyAppPackage.zip) and attach it to the release via drag & drop.

  8. Click the Publish button to create the release.