Github Torrent Action

Here’s something I’ve been meaning to get to for a while, and finally got a chance. Enter GitHub Torrent Action!

This lightweight action allows you to create and publish torrents for your release assets. Can come in handy if the files are large.

While GitHub does not limit bandwidth usage for releases, it doesn’t mean that they guarantee fast download speeds at all times. The action itself uses the assets’ HTTP links as web seeds, so, download time wise, the result should be a net win anyway.

Example configuration:

name: Release

on:
  push:
    tags:
      - "v*"

jobs:
  release:
    runs-on: ubuntu-latest
    permissions:
      contents: write
    steps:
      - name: Checkout repository
        uses: actions/checkout@v4

        # Create torrents first
      - name: Create torrents
        uses: devopsx/action-torrent@v1
        with:
          token: ${{ secrets.GITHUB_TOKEN }}
          files: |
            dist/index.js
            src/*

        # And then upload torrents together with corresponding assets
      - name: Release
        uses: softprops/action-gh-release@v2
        with:
          token: ${{ secrets.GITHUB_TOKEN }}
          name: ${{ github.ref_name }}
          fail_on_unmatched_files: true
          files: | # same as above, but with addition of torrents/* directory
            dist/index.js
            src/*
            torrents/*

Here we create a torrent for dist/index.js, and for every file in src/, then release the assets and the corresponding torrents together.

This the “local” mode, meaning torrents are generated before the release. There’s also a “remote” mode, which finds release assets automatically. You’ll find more about it in the readme.

Good luck, and keep seeding!

Comments