fork/static-web-server
git clone https://git.julia.blue/fork/static-web-server
c298a6d
allow-symlink
1name : release-docker-devel 2 3on : 4push : 5branches : 6- master 7paths : 8- .github/workflows/release.docker.devel.yml 9- .cargo/config.toml 10- Cargo.lock 11- Cargo.toml 12- src/** 13 14env : 15TARGET_DIR : ./target 16 17jobs : 18build-release : 19runs-on : ubuntu-22.04 20env : 21CARGO_BIN : cargo 22# Emit backtraces on panics. 23RUST_BACKTRACE : 1 24# SWS features for Cargo build 25CARGO_FEATURES : "--features=all" 26# When CARGO_BIN is set to CROSS, this is set to `--target matrix.target`. 27TARGET_FLAGS : "" 28strategy : 29matrix : 30build : 31# DOCKER: jobs just work only for one target. 32# If multiple targets are needed then refactor the workflow and the 'devel' Dockerfile to be Docker Multiarch. 33- linux-musl 34include : 35- build : linux-musl 36arch : linux/amd64 37rust : stable 38target : x86_64-unknown-linux-musl 39- build : linux-gnu 40arch : linux/amd64 41rust : stable 42target : x86_64-unknown-linux-gnu 43 44outputs : 45target : ${{ steps.target.outputs.target }} 46arch : ${{ steps.arch.outputs.arch }} 47 48steps : 49- name : Checkout repository 50uses : actions/checkout@v4 51with : 52fetch-depth : 1 53- name : Install Rust 54uses : dtolnay/rust-toolchain@stable 55with : 56toolchain : ${{ matrix.rust }} 57target : ${{ matrix.target }} 58- name : Set up Cross 59shell : bash 60run : | 61echo "Installing cross..." 62curl -sSL \ 63"https://github.com/cross-rs/cross/releases/download/v0.2.5/cross-${{ matrix.target }}.tar.gz" \ 64| sudo tar zxf - -C /usr/local/bin/ cross cross-util 65cross -V 66echo "CARGO_BIN=/usr/local/bin/cross" >> $GITHUB_ENV 67echo "TARGET_FLAGS=--target=${{ matrix.target }}" >> $GITHUB_ENV 68echo "TARGET_DIR=${{ env.TARGET_DIR }}/${{ matrix.target }}" >> $GITHUB_ENV 69 70- name : Show command used for Cargo 71run : | 72echo "cargo command is: ${{ env.CARGO_BIN }}" 73echo "target dir is: ${{ env.TARGET_DIR }}" 74- name : Build release binary 75run : | 76${{ env.CARGO_BIN }} build --bin static-web-server -vv --release ${{ env.CARGO_FEATURES }} ${{ env.TARGET_FLAGS }} 77- name : Define target output 78id : target 79run : | 80echo 'target=${{ matrix.target }}' >> "$GITHUB_OUTPUT" 81- name : Define arch output 82id : arch 83run : | 84echo 'arch=${{ matrix.arch }}' >> "$GITHUB_OUTPUT" 85- name : Cache binary 86uses : actions/cache@v4 87with : 88path : ${{ env.TARGET_DIR }}/release 89# short-lived cache: https://github.com/actions/cache/blob/main/caching-strategies.md#creating-a-short-lived-cache 90key : cache-${{ github.sha }}-${{ matrix.target }} 91 92# NOTE: only one arch/target per Docker "kind" is supported. 93# If multiple targets are needed then refactor the workflow and the 'devel' Dockerfile to be Docker Multiarch. 94docker-image : 95needs : [ 'build-release' ] 96runs-on : ubuntu-22.04 97permissions : 98contents : read 99packages : write 100strategy : 101matrix : 102kind : 103- scratch 104- debian 105include : 106- kind : scratch 107tag : devel 108- kind : debian 109tag : devel-debian 110target : 111- ${{ needs.build-release.outputs.target }} 112arch : 113- ${{ needs.build-release.outputs.arch }} 114steps : 115- name : Checkout repository 116uses : actions/checkout@v4 117with : 118fetch-depth : 1 119- name : Restore cache 120uses : actions/cache/restore@v4 121with : 122path : ${{ env.TARGET_DIR }}/${{ matrix.target }}/release 123key : cache-${{ github.sha }}-${{ matrix.target }} 124- name : Copy binary 125run : | 126cp ${{ env.TARGET_DIR }}/${{ matrix.target }}/release/static-web-server ./docker/devel/ 127 128- name : Login to ghcr.io 129uses : docker/login-action@v3 130with : 131registry : ghcr.io 132username : ${{ github.actor }} 133password : ${{ secrets.GITHUB_TOKEN }} 134- name : Build and push (${{ matrix.kind }}) 135uses : docker/build-push-action@v6 136with : 137push : true 138context : . 139platforms : ${{ matrix.arch }} 140file : ./docker/devel/Dockerfile.${{ matrix.kind }} 141tags : ghcr.io/static-web-server/static-web-server:${{ matrix.tag }}