Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
cxreiff committed Jul 21, 2024
0 parents commit cfe7286
Show file tree
Hide file tree
Showing 15 changed files with 6,298 additions and 0 deletions.
94 changes: 94 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
name: ci

on:
push:
branches: [main]
pull_request:
branches: [main]

env:
CARGO_TERM_COLOR: always
RUSTFLAGS: --deny warnings
RUSTDOCFLAGS: --deny warnings

jobs:
test:
name: tests
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: checkout
uses: actions/checkout@v4

- name: install rust
uses: dtolnay/rust-toolchain@stable

- name: install dependencies
run: sudo apt-get update; sudo apt-get install --no-install-recommends libasound2-dev libudev-dev libwayland-dev libxkbcommon-dev

- name: populate target directory from cache
uses: Leafwing-Studios/cargo-cache@v2

- name: run tests
run: |
cargo test --workspace --all-features --all-targets
# Workaround for https://github.com/rust-lang/cargo/issues/6669
cargo test --workspace --all-features --doc
clippy:
name: clippy
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: checkout
uses: actions/checkout@v4

- name: install rust
uses: dtolnay/rust-toolchain@stable
with:
components: clippy

- name: install dependencies
run: sudo apt-get update; sudo apt-get install --no-install-recommends libasound2-dev libudev-dev libwayland-dev libxkbcommon-dev

- name: populate target directory from cache
uses: Leafwing-Studios/cargo-cache@v2

- name: run clippy
run: cargo clippy --workspace --all-targets --all-features -- --deny warnings

format:
name: format
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: checkout
uses: actions/checkout@v4

- name: install rust
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt

- name: run cargo fmt
run: cargo fmt --all -- --check

doc:
name: docs
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: checkout
uses: actions/checkout@v4

- name: install rust
uses: dtolnay/rust-toolchain@stable

- name: install dependencies
run: sudo apt-get update; sudo apt-get install --no-install-recommends libasound2-dev libudev-dev libwayland-dev libxkbcommon-dev

- name: populate target directory from cache
uses: Leafwing-Studios/cargo-cache@v2

- name: check documentation
run: cargo doc --workspace --all-features --document-private-items --no-deps
144 changes: 144 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
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.platform == 'linux' }}
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 }}

# 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
- build
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/target
.cargo/config.toml
Loading

0 comments on commit cfe7286

Please sign in to comment.