diff --git a/.github/workflows/packages.yaml b/.github/workflows/packages.yaml index 1b4492b..57dcb3f 100644 --- a/.github/workflows/packages.yaml +++ b/.github/workflows/packages.yaml @@ -220,3 +220,56 @@ jobs: run: | docker buildx imagetools inspect ${{ steps.prepare.outputs.docker_image }}:${{ steps.prepare.outputs.version }} + rust: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Prepare + id: prepare + run: | + DOCKER_IMAGE=ghcr.io/mentos1386/rust + DOCKER_PLATFORMS=linux/amd64,linux/arm64 + VERSION=1.48.0 + + TAGS="--tag ${DOCKER_IMAGE}:${VERSION} --tag ${DOCKER_IMAGE}:latest" + + echo ::set-output name=docker_image::${DOCKER_IMAGE} + echo ::set-output name=version::${VERSION} + echo ::set-output name=buildx_args::--platform ${DOCKER_PLATFORMS} \ + --build-arg VERSION=${VERSION} \ + --build-arg BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ') \ + --build-arg VCS_REF=${GITHUB_SHA::8} \ + --cache-from "type=local,src=/tmp/.buildx-cache" \ + --cache-to "type=local,dest=/tmp/.buildx-cache" \ + ${TAGS} --file ./packages/Dockerfile.rust . + - name: Cache Docker layers + uses: actions/cache@v2 + with: + path: /tmp/.buildx-cache + key: ${{ runner.os }}-rust-${{ github.sha }} + restore-keys: | + ${{ runner.os }}-rust- + - name: Set up QEMU + uses: docker/setup-qemu-action@v1 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + - name: Docker Buildx (build) + run: | + docker buildx build --output "type=image,push=false" ${{ steps.prepare.outputs.buildx_args }} + - name: Login to Github Registry + if: success() && github.event_name != 'pull_request' + uses: docker/login-action@v1 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.CR_PAT }} + - name: Docker Buildx (push) + if: success() && github.event_name != 'pull_request' + run: | + docker buildx build --output "type=image,push=true" ${{ steps.prepare.outputs.buildx_args }} + - name: Inspect image + if: always() && github.event_name != 'pull_request' + run: | + docker buildx imagetools inspect ${{ steps.prepare.outputs.docker_image }}:${{ steps.prepare.outputs.version }} + diff --git a/packages/Dockerfile.rust b/packages/Dockerfile.rust new file mode 100644 index 0000000..15de0c9 --- /dev/null +++ b/packages/Dockerfile.rust @@ -0,0 +1,31 @@ +FROM alpine:3.12 + +RUN apk add --no-cache \ + ca-certificates \ + gcc + +ARG VERSION=1.48.0 + +ENV RUSTUP_HOME=/usr/local/rustup \ + CARGO_HOME=/usr/local/cargo \ + PATH=/usr/local/cargo/bin:$PATH \ + RUST_VERSION=${VERSION} + +RUN set -eux; \ + apkArch="$(apk --print-arch)"; \ + case "$apkArch" in \ + x86_64) rustArch='x86_64-unknown-linux-musl'; rustupSha256='8ab4f7759e22c308b49d737b5dc055c0d334f730632fdc6a169eda033983b846' ;; \ + aarch64) rustArch='aarch64-unknown-linux-musl'; rustupSha256='b3f15d01db21e4e9f192a81bfcbbb72e9055f6b01b4d0893b24f9f6c9f9d2b92' ;; \ + *) echo >&2 "unsupported architecture: $apkArch"; exit 1 ;; \ + esac; \ + url="https://static.rust-lang.org/rustup/archive/1.23.0/${rustArch}/rustup-init"; \ + wget "$url"; \ + echo "${rustupSha256} *rustup-init" | sha256sum -c -; \ + chmod +x rustup-init; \ + ./rustup-init -y --no-modify-path --profile minimal --default-toolchain $RUST_VERSION --default-host ${rustArch}; \ + rm rustup-init; \ + chmod -R a+w $RUSTUP_HOME $CARGO_HOME; \ + rustup --version; \ + cargo --version; \ + rustc --version; + diff --git a/workspace.toml b/workspace.toml index bb66c92..eb5e88e 100644 --- a/workspace.toml +++ b/workspace.toml @@ -34,3 +34,7 @@ version = "1.3.0" name = "mosh" version = "master" +[[templates."package-action".vars.jobs]] +name = "rust" +version = "1.48.0" +