Skip to content

Commit

Permalink
Improved github action
Browse files Browse the repository at this point in the history
- Use cargo-binstall for cargo-make and cargo-vita
- Added workflow_dispatch to action
- Added a parameter to override rust toolchain
  • Loading branch information
nikarh committed Oct 14, 2023
1 parent 92f02a8 commit 1d708b9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 17 deletions.
10 changes: 8 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@

name: Publish Docker image

on:
push:
branches: [main]
schedule:
# Every Monday at 02:00 UTC
- cron: '0 2 * * 1'
- cron: "0 2 * * 1"
workflow_dispatch:
inputs:
rust_toolchain:
description: "Rust toolchain"
required: true
default: "nightly"

jobs:
push_to_registry:
Expand Down Expand Up @@ -38,3 +43,4 @@ jobs:
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: "RUST_TOOLCHAIN=${{ github.event.inputs.rust_toolchain || 'nightly' }}"
20 changes: 5 additions & 15 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,25 +1,15 @@
FROM vitasdk/vitasdk

ARG CARGO_MAKE_VERSION=0.37.0

ENV RUSTUP_HOME=/usr/local/rustup \
CARGO_HOME=/usr/local/cargo \
PATH=/usr/local/cargo/bin:$PATH

# Install rust nightly with all the components required to build std
# build-base (mainly cc and ld) is required to build std.
RUN apk add --no-cache rustup build-base jq perl clang llvm && \
rustup-init -y --default-toolchain nightly -c rustfmt -c rustc-dev -c rust-src
RUN apk add --no-cache rustup build-base jq perl clang llvm

RUN curl https://api.github.com/repos/vita-rust/cargo-vita/releases/latest | \
jq -r '.assets[] | select(.name|contains("x86_64-unknown-linux-musl.tar.gz")) | .browser_download_url' | \
xargs -n1 curl -LsSf -o /tmp/cargo-vita.tar.gz && \
tar -zxvf /tmp/cargo-vita.tar.gz -C /tmp && \
mv /tmp/cargo-vita-*linux-musl/cargo-vita "${CARGO_HOME}/bin" && \
rm -rf /tmp/cargo-vita*
ARG RUST_TOOLCHAIN=nightly
RUN rustup-init -y --default-toolchain ${RUST_TOOLCHAIN} -c rust-src

# Install cargo make. Use a pre-build binary instead of compiling it
RUN curl -LsSf -o /tmp/cargo-make.zip https://github.com/sagiegurari/cargo-make/releases/download/${CARGO_MAKE_VERSION}/cargo-make-v${CARGO_MAKE_VERSION}-x86_64-unknown-linux-musl.zip && \
unzip -j /tmp/cargo-make.zip -d /tmp/cargo-make && \
mv /tmp/cargo-make/cargo-make "${CARGO_HOME}/bin" && \
rm -rf /tmp/cargo-make*
RUN curl -L --proto '=https' --tlsv1.2 -sSf https://raw.githubusercontent.com/cargo-bins/cargo-binstall/main/install-from-binstall-release.sh | ash && \
cargo binstall --no-confirm --no-symlinks cargo-make cargo-vita

0 comments on commit 1d708b9

Please sign in to comment.