• Stars
    star
    429
  • Rank 101,271 (Top 2 %)
  • Language
    TypeScript
  • License
    MIT License
  • Created about 5 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Upload files to a GitHub release

Upload files to a GitHub release GitHub Actions Workflow

This action allows you to select which files to upload to the just-tagged release. It runs on all operating systems types offered by GitHub.

Input variables

You must provide:

  • file: A local file to be uploaded as the asset.

Optional Arguments

  • repo_token: Defaults to github.token.
  • tag: The tag to upload into. If you want the current event's tag or branch name, use ${{ github.ref }} (the refs/tags/ and refs/heads/ prefixes will be automatically stripped). Defaults to github.ref.
  • asset_name: The name the file gets as an asset on a release. Use $tag to include the tag name. When not provided it will default to the filename. This is not used if file_glob is set to true.
  • file_glob: If set to true, the file argument can be a glob pattern (asset_name is ignored in this case) (Default: false)
  • overwrite: If an asset with the same name already exists, overwrite it (Default: false).
  • promote: If a prerelease already exists, promote it to a release (Default: false).
  • prerelease: Mark the release as a pre-release (Default: false).
  • make_latest: Mark the release as the latest release for the repository (Default: true).
  • release_name: Explicitly set a release name. (Defaults: implicitly same as tag via GitHub API).
  • body: Content of the release text (Default: "").
  • repo_name: Specify the name of the GitHub repository in which the GitHub release will be created, edited, and deleted. If the repository is other than the current, it is required to create a personal access token with repo, user, admin:repo_hook scopes to the foreign repository and add it as a secret. (Default: current repository).

Output variables

  • browser_download_url: The publicly available URL of the asset.

Usage

This usage assumes you want to build on tag creations only. This is a common use case as you will want to upload release binaries for your tags.

Simple example:

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/mything
        asset_name: mything
        tag: ${{ github.ref }}
        overwrite: true
        body: "This is my release text"

Complex example with more operating systems:

name: Publish

on:
  push:
    tags:
      - '*'

jobs:
  publish:
    name: Publish for ${{ matrix.os }}
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        include:
          - os: ubuntu-latest
            artifact_name: mything
            asset_name: mything-linux-amd64
          - os: windows-latest
            artifact_name: mything.exe
            asset_name: mything-windows-amd64
          - os: macos-latest
            artifact_name: mything
            asset_name: mything-macos-amd64

    steps:
    - uses: actions/checkout@v3
    - name: Build
      run: cargo build --release --locked
    - name: Upload binaries to release
      uses: svenstaro/upload-release-action@v2
      with:
        repo_token: ${{ secrets.GITHUB_TOKEN }}
        file: target/release/${{ matrix.artifact_name }}
        asset_name: ${{ matrix.asset_name }}
        tag: ${{ github.ref }}

Example with file_glob:

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*
        tag: ${{ github.ref }}
        overwrite: true
        file_glob: true

Example for creating a release in a foreign repository using repo_name:

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_name: owner/repository-name
        # A personal access token for the GitHub repository in which the release will be created and edited.
        # It is recommended to create the access token with the following scopes: `repo, user, admin:repo_hook`.
        repo_token: ${{ secrets.YOUR_PERSONAL_ACCESS_TOKEN }}
        file: target/release/mything
        asset_name: mything
        tag: ${{ github.ref }}
        overwrite: true
        body: "This is my release text"

Example for feeding a file from repo to the body tag:

This example covers following points:

  • Reading a file present on the repo. For example, release.md which is placed in root directory of the repo.
  • Modify & push the release.md file before triggering this action (create tag for this example) to dynamically change the body of the release.
name: Publish

on:
  push:
    tags:
      - '*'

jobs:

  build:
    name: Publish binaries
    runs-on: ubuntu-latest
         
    steps:
      - uses: actions/checkout@v3

      # This step reads a file from repo and use it for body of the release
      # This works on any self-hosted runner OS
      - name: Read release.md and use it as a body of new release
        id: read_release
        shell: bash
        run: |
          r=$(cat path/to/release.md)                       # <--- Read release.md (Provide correct path as per your repo)
          r="${r//'%'/'%25'}"                               # Multiline escape sequences for %
          r="${r//$'\n'/'%0A'}"                             # Multiline escape sequences for '\n'
          r="${r//$'\r'/'%0D'}"                             # Multiline escape sequences for '\r'
          echo "RELEASE_BODY=$r" >> $GITHUB_OUTPUT          # <--- Set environment variable

      - name: Upload Binaries to Release
        uses: svenstaro/upload-release-action@v2
        with:
          repo_token: ${{ secrets.GITHUB_TOKEN }}
          tag: ${{ github.ref }}
          body: |
            ${{ steps.read_release.outputs.RELEASE_BODY }}  # <--- Use environment variables that was created earlier

Permissions

This actions requires writes access to the release. If you are using granular permissions in your workflow, you will need to add the contents: write permission to the token:

permissions:
  contents: write

Releasing

To release this Action:

More Repositories

1

genact

🌀 A nonsense activity generator
Rust
7,449
star
2

miniserve

🌟 For when you really just want to serve some files over HTTP right now!
Rust
4,653
star
3

rofi-calc

🖩 Do live calculations in rofi!
C
756
star
4

cargo-profiler

Cargo subcommand to profile binaries
Rust
426
star
5

rust-web-boilerplate

Rust web template for modern web backend applications
Rust
286
star
6

bvh

A fast BVH using SAH in rust
Rust
226
star
7

wmfocus

Visually focus windows by label
Rust
195
star
8

flamejam

A generic game jam application with ratings and comments using Flask
HTML
140
star
9

memefs

Mount your memes using FUSE
Rust
131
star
10

glsl-language-server

Language server implementation for GLSL
C++
104
star
11

proxyboi

A super simple reverse proxy with TLS support
Rust
81
star
12

dwarf_fortress_unfuck

Unfucking Dwarf Fortress
C++
80
star
13

dummyhttp

Super simple HTTP server that replies a fixed body with a fixed response code
Rust
56
star
14

pseudoform

Pseudoform is a community-driven collaboration project that aims to create an involving and brain-melting first-person puzzle-solving game.
C++
38
star
15

trac0r

A fast real time physically based renderer
C++
29
star
16

upx-action

Strips and runs upx on binaries
JavaScript
25
star
17

mt940-rs

A MT940 parser in Rust
Rust
22
star
18

python-web-boilerplate

Python web template for modern web backend applications
Python
21
star
19

keycloak-http-webhook-provider

A Keycloak provider that posts events to a URL via HTTP POST as JSON
Java
20
star
20

derp

The derp game engine in D
D
20
star
21

gamejam

This is a gamejam project for all kinds of jams.
Lua
19
star
22

wiresmith

Auto-config WireGuard clients into a mesh
Rust
17
star
23

lglive

live.linuX-gamers live gaming distro
Shell
16
star
24

site24x7_exporter

A Prometheus compatible exporter for site24x7.com
Rust
13
star
25

crabcluster

A simple integrated container orchestration solution
Rust
12
star
26

pytest-colordots

Colorizes the progress indicators
Python
12
star
27

dotfiles

Various dotfiles from my machines
Vim Script
12
star
28

minimal-examples

A bunch of small standalone programs
C++
11
star
29

proby

📡 Check whether hosts are reachable on certain ports and return result on HTTP
Rust
10
star
30

playgrounds

Just some playing around with physics.
C++
9
star
31

Spacescape

A space skybox tool using Ogre3D
C++
8
star
32

fints-institute-db

A library and CLI tool to access FinTS access information for many German banks
Rust
6
star
33

talks

Talks for conferences and such
HTML
5
star
34

fints-rs

A compliant FinTS implementation
Rust
5
star
35

vulkanology

Test Vulkan compute shaders using Rust
Rust
5
star
36

qponies

Desktop ponies using qml
C++
5
star
37

NoisyHunter

Implementation of http://www.squidi.net/three/entry.php?id=85
C++
5
star
38

Pseudoform-2

C++
4
star
39

piplayer

Receive a command, play a song
Rust
4
star
40

bankthing

💰 A thing that does stuff with banks
Python
3
star
41

instacheer

Instant cheer for your desktop!
C++
3
star
42

benchy

FOSS cross-platform desktop benchmarking tool
C++
3
star
43

MegaGong

School gong for my class
C++
2
star
44

ilswlol

Wer weiss?
Python
2
star
45

arkenon

Stuff with spaceships
C++
2
star
46

pong4p

4-player multiplayer pong
Python
2
star
47

minitraderoute

A Mini Metro-inspired space trading game
Rust
2
star
48

txt2vid

A text to video renderer
2
star
49

windowcrap

Experimental crap for your desktop!
C++
2
star
50

esp32-toys

Just playing around with ESP32
Python
2
star
51

ssl-proxy-docker

Dockerized version of https://github.com/suyashkumar/ssl-proxy
Dockerfile
2
star
52

rust-web-experiments

Various experiments with rust in the web
Rust
2
star
53

overpower

CLI tool to benchmark web servers with nice output
Rust
2
star
54

rust-timescale-sqlx-rocket

A little integration test of Rust, TimescaleDB, sqlx, and Rocket
Rust
2
star
55

lolpi

A simple implementation of Bellard's formula for calculating PI.
C++
2
star
56

uefi-playground

Experiments with UEFI
Makefile
2
star
57

innojam13

IGJam #13
Rust
1
star
58

cargo-sweb

Simple and convenient cargo subcommand to develop web applications
1
star
59

gameservers

Instant game servers for various games
Shell
1
star
60

taxi-simulation

Schizl
Rust
1
star
61

innojam8

InnoGames Game Jam 8
JavaScript
1
star
62

infinerator

Image generator to generate every possible combination of a given resolution and color depth
C++
1
star
63

pink-fluffy-unicorns

Interactive Visual Computing using POVRay
TeX
1
star
64

qemu-espressif-docker

A container image containing espressif-qemu
Dockerfile
1
star
65

caca

Copy And Convert Audio
Python
1
star
66

fredjam2018

Rust
1
star
67

svenstaro

My GitHub profile page
1
star
68

gamedev-starter-packs

Starter packs for various languages
Lua
1
star
69

docker-archlinux-bootstrap

Arch Linux Docker base image that is generated from the official bootstrap
Shell
1
star
70

epaper-frame

A color e-ink-based picture frame driven by an ESP32
Rust
1
star
71

docker-phoronix-test-suite

A Docker image featuring a ready-to-run installation of the Phoronix Test Suite
Dockerfile
1
star
72

uni-projekt

Projekt Mikrocomputer
Python
1
star
73

rust-python-experiment

Experiments involving Rust + Python
Rust
1
star
74

strapon

Modern C++14 helpers for game stuff
C++
1
star