upload archive in workflow #8
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: release | |
on: | |
push: | |
tags: | |
- "v[0-9]+.[0-9]+.[0-9]+*" | |
workflow_dispatch: | |
inputs: | |
version: | |
description: 'version number in the format `v1.2.3`' | |
required: true | |
type: string | |
env: | |
# The base filename of the binary produced by `cargo build`. | |
BINARY: lifecycler | |
# The name to use for the packaged application produced by this workflow. | |
PACKAGE_NAME: lifecycler | |
# The itch.io page to upload to, in the format: `user-name/project-name`. | |
# Comment this out to disable. | |
ITCH_TARGET: cxreiff/lifecycler | |
# The organization or author that owns the rights to the game. | |
OWNER: cxreiff | |
# The path to the assets directory. | |
ASSETS_DIR: assets | |
# Whether packages produced by this workflow should be uploaded to the Github release. | |
UPLOAD_PACKAGES_TO_GITHUB_RELEASE: true | |
# Before enabling LFS, please take a look at GitHub's documentation for costs and quota limits: | |
# https://docs.github.com/en/repositories/working-with-files/managing-large-files/about-storage-and-bandwidth-usage | |
USE_GIT_LFS: false | |
jobs: | |
# Determine the version number for this workflow. | |
get-version: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Get version number from tag | |
id: tag | |
run: echo "tag=${GITHUB_REF#refs/tags/}" >> "${GITHUB_OUTPUT}" | |
outputs: | |
# Use the input from workflow dispatch, or fall back to the git tag. | |
version: ${{ inputs.version || steps.tag.outputs.tag }} | |
create-release: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: taiki-e/create-gh-release-action@v1 | |
with: | |
# (optional) Path to changelog. | |
# changelog: CHANGELOG.md | |
# (required) GitHub token for creating GitHub Releases. | |
token: ${{ secrets.GITHUB_TOKEN }} | |
upload-assets: | |
needs: create-release | |
strategy: | |
matrix: | |
include: | |
- target: x86_64-unknown-linux-gnu | |
os: ubuntu-latest | |
- target: x86_64-apple-darwin | |
os: macos-latest | |
- target: x86_64-pc-windows-msvc | |
os: windows-latest | |
runs-on: ${{ matrix.os }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: install dependencies (linux) | |
if: ${{ matrix.os == 'ubuntu-latest' }} | |
run: sudo apt-get update; sudo apt-get install --no-install-recommends libasound2-dev libudev-dev libwayland-dev libxkbcommon-dev | |
- uses: taiki-e/upload-rust-binary-action@v1 | |
with: | |
# (required) Comma-separated list of binary names (non-extension portion of filename) to build and upload. | |
# Note that glob pattern is not supported yet. | |
bin: ${{ env.PACKAGE_NAME }} | |
# (optional) Comma-separated list of additional files to be included to archive. | |
# Note that glob pattern is not supported yet. | |
# include: LICENSE,README.md | |
# (optional) Target triple, default is host triple. | |
# This is optional but it is recommended that this always be set to | |
# clarify which target you are building for if macOS is included in | |
# the matrix because GitHub Actions changed the default architecture | |
# of macos-latest since macos-14. | |
target: ${{ matrix.target }} | |
# (optional) On which platform to distribute the `.tar.gz` file. | |
# [default value: unix] | |
# [possible values: all, unix, windows, none] | |
tar: none | |
# (optional) On which platform to distribute the `.zip` file. | |
# [default value: windows] | |
# [possible values: all, unix, windows, none] | |
zip: all | |
# (required) GitHub token for uploading assets to GitHub Releases. | |
token: ${{ secrets.GITHUB_TOKEN }} | |
- name: upload artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: binary | |
path: | | |
${{ env.PACKAGE_NAME }} | |
# Get itch.io target from env, because the `env` context can't be used in the `if:` condition of a job. | |
# See: https://docs.github.com/en/actions/learn-github-actions/contexts#context-availability | |
get-itch-target: | |
runs-on: ubuntu-latest | |
steps: | |
- name: do nothing | |
run: 'true' | |
outputs: | |
itch-target: ${{ env.ITCH_TARGET }} | |
# Upload all packages to itch.io. | |
upload-to-itch: | |
runs-on: ubuntu-latest | |
needs: | |
- get-version | |
- get-itch-target | |
- upload-assets | |
env: | |
VERSION: ${{ needs.get-version.outputs.version }} | |
if: ${{ needs.get-itch-target.outputs.itch-target != '' }} | |
steps: | |
- name: download all packages | |
uses: actions/download-artifact@v4 | |
with: | |
pattern: package-* | |
path: tmp | |
- name: install butler | |
run: | | |
curl -L -o butler.zip 'https://broth.itch.ovh/butler/linux-amd64/LATEST/archive/default' | |
unzip butler.zip | |
chmod +x butler | |
./butler -V | |
- name: upload all packages to itch.io | |
env: | |
BUTLER_API_KEY: ${{ secrets.BUTLER_CREDENTIALS }} | |
run: | | |
for channel in $(ls tmp); do | |
./butler push \ | |
--fix-permissions \ | |
--userversion='${{ env.VERSION }}' \ | |
tmp/"${channel}"/* \ | |
'${{ env.ITCH_TARGET }}':"${channel#package-}" | |
done | |