A GitHub Action to easily attach files to a GitHub release.
This action allows you to attach files to a GitHub release using glob patterns to specify the files.
- name: Attach Files to Release uses: stacksjs/[email protected] with: files: | bin/app-linux-x64 bin/app-linux-arm64 bin/app-windows-x64.exe bin/app-darwin-x64 bin/app-darwin-arm64 # Optional parameters # token: ${{ secrets.GITHUB_TOKEN }} # tag: ${{ github.ref_name }} # draft: false # prerelease: false # note: 'Release notes'
The files input supports full glob patterns powered by @actions/glob:
- name: Attach Files with Glob Patterns uses: stacksjs/[email protected] with: files: | # Match all .tar.gz files in specific directories ion-binaries/ion-linux-x64/_.tar.gz ion-binaries/ion-linux-arm64/_.tar.gz ion-binaries/ion-darwin-x64/_.tar.gz ion-binaries/ion-darwin-arm64/_.tar.gz # Match all .zip files ion-binaries/ion-windows-x64/_.zip ion-binaries/ion-windows-arm64/_.zip # Or use wildcards dist/**/*.zip build/**/app-_
| Name | Description | Required | Default |
|---|---|---|---|
| files | List of files to attach to the release | Yes | N/A |
| token | GitHub token | No | ${{ github.token }} |
| tag | The tag name for the release | No | ${{ github.ref_name }} |
| draft | Create a draft release | No | false |
| prerelease | Mark as prerelease | No | false |
| note | Release notes | No | (empty) |
| homebrewFormula | Path to the Homebrew formula template file | No | (empty) |
| homebrewRepo | Repository to update the Homebrew formula in (format: owner/repo) | No | (empty) |
| homebrewBranch | Branch name in the Homebrew repository to commit to | No | main |
| homebrewPath | Path in the Homebrew repository where formulas are stored | No | Formula |
| homebrewCommitFormat | Commit message format for Homebrew formula updates | No | update: {{ formula }} to {{ version }} |
name: Releaser on: push: tags: - 'v_' jobs: npm: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 # Build your application - name: Build run: | npm ci npm run build # Create a release and attach files - name: Create Release and Attach Files uses: stacksjs/[email protected] with: files: | dist/app.zip dist/app.tar.gz
This action can automatically update a Homebrew formula in a tap repository when you create a release.
Important: The Homebrew formula update feature requires a GitHub token with write permissions to the target repository. The default GITHUB_TOKEN only has access to the current repository, not to external repositories.
To update a formula in a different repository:
- Create a Personal Access Token (PAT) with the
reposcope (or at minimumcontents:write) - Store it as a repository secret (e.g.,
HOMEBREW_TOKEN) - Pass this token to the action using the
tokenparameter
name: Release with Homebrew Update on: push: tags: - 'v*' jobs: release: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 # Build your application - name: Build run: | npm ci npm run build # Create a release, attach files, and update Homebrew formula - name: Create Release, Attach Files, and Update Homebrew Formula uses: stacksjs/[email protected] with: files: | dist/app-darwin-arm64.tar.gz dist/app-darwin-x64.tar.gz dist/app-linux-arm64.tar.gz dist/app-linux-x64.tar.gz homebrewFormula: .github/homebrew-formula.rb homebrewRepo: yourusername/homebrew-tap homebrewPath: Formula homebrewCommitFormat: 'chore(homebrew): update {{ formula }} to version {{ version }}' token: ${{ secrets.HOMEBREW_TOKEN }} # PAT with write access to the homebrew repo
Create a template file (e.g., .github/homebrew-formula.rb) that includes placeholders for the version and download URLs:
class YourApp < Formula desc "Your application description" homepage "https://github.com/yourusername/yourrepo" version "{{ version }}" on_macos do if Hardware::CPU.arm? url "{{ app-darwin-arm64.tar.gz_url }}" sha256 "UPDATE_WITH_ACTUAL_SHA_AFTER_RELEASE" else url "{{ app-darwin-x64.tar.gz_url }}" sha256 "UPDATE_WITH_ACTUAL_SHA_AFTER_RELEASE" end end on_linux do if Hardware::CPU.arm? url "{{ app-linux-arm64.tar.gz_url }}" sha256 "UPDATE_WITH_ACTUAL_SHA_AFTER_RELEASE" else url "{{ app-linux-x64.tar.gz_url }}" sha256 "UPDATE_WITH_ACTUAL_SHA_AFTER_RELEASE" end end def install bin.install "yourapp" end test do system "#{bin}/yourapp", "--version" end end
Template Variables:
{{ version }}- The version number (without the 'v' prefix if present in the tag){{ filename_url }}- The download URL for each uploaded asset (replace 'filename' with the actual filename)
name: Release with Notes on: push: tags: - 'v_' jobs: release: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 with: fetch-depth: 0 # Generate release notes - name: Generate Release Notes id: release-notes run: echo "NOTES=$(./scripts/generate-notes.sh)" >> $GITHUB_OUTPUT # Create a release and attach files - name: Create Release and Attach Files uses: stacksjs/[email protected] with: files: | dist/_.zip dist/*.tar.gz note: ${{ steps.release-notes.outputs.NOTES }} draft: true prerelease: ${{ contains(github.ref, '-beta') || contains(github.ref, '-alpha') }}
bun testPlease see our releases page for more information on what has changed recently.
Please see CONTRIBUTING for details.
For help, discussion about best practices, or any other conversation that would benefit from being searchable:
For casual chit-chat with others using this package:
Join the Stacks Discord Server
"Software that is free, but hopes for a postcard." We love receiving postcards from around the world showing where Stacks is being used! We showcase them on our website too.
Our address: Stacks.js, 12665 Village Ln #2306, Playa Vista, CA 90094, United States 🌎
We would like to extend our thanks to the following sponsors for funding Stacks development. If you are interested in becoming a sponsor, please reach out to us.
The MIT License (MIT). Please see LICENSE for more information.
Made with 💙
