Upgrade dependencies #894
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: Build | |
on: [push] | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Prepare tags | |
id: prep | |
run: | | |
DOCKER_IMAGE=creatiwity/siren | |
VERSION=noop | |
if [ "${{ github.event_name }}" = "schedule" ]; then | |
VERSION=nightly | |
elif [[ $GITHUB_REF == refs/tags/* ]]; then | |
VERSION=${GITHUB_REF#refs/tags/} | |
elif [[ $GITHUB_REF == refs/heads/* ]]; then | |
VERSION=$(echo ${GITHUB_REF#refs/heads/} | sed -r 's#/+#-#g') | |
if [ "${{ github.event.repository.default_branch }}" = "$VERSION" ]; then | |
VERSION=edge | |
fi | |
elif [[ $GITHUB_REF == refs/pull/* ]]; then | |
VERSION=pr-${{ github.event.number }} | |
fi | |
TAGS="${DOCKER_IMAGE}:${VERSION}" | |
if [[ $VERSION =~ ^v[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then | |
MINOR=${VERSION%.*} | |
MAJOR=${MINOR%.*} | |
TAGS="$TAGS,${DOCKER_IMAGE}:${MINOR},${DOCKER_IMAGE}:${MAJOR},${DOCKER_IMAGE}:latest" | |
elif [ "${{ github.event_name }}" = "push" ]; then | |
TAGS="$TAGS,${DOCKER_IMAGE}:sha-${GITHUB_SHA::8}" | |
fi | |
echo "version=${VERSION}" >> $GITHUB_OUTPUT | |
echo "tags=${TAGS}" >> $GITHUB_OUTPUT | |
echo "created=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> $GITHUB_OUTPUT | |
- name: Caching MUSL | |
uses: actions/cache@v2 | |
with: | |
path: | | |
~/.cargo/registry | |
~/.cargo/git | |
target | |
key: ${{ runner.os }}-cargo-musl-${{ hashFiles('**/Cargo.lock') }} | |
- name: Build for MUSL | |
run: | | |
mkdir -p ~/.cargo/{git,registry} | |
mkdir -p $GITHUB_WORKSPACE/target | |
docker pull clux/muslrust:stable | |
docker run \ | |
-v ~/.cargo/registry:/root/.cargo/registry \ | |
-v ~/.cargo/git:/root/.cargo/git \ | |
-v $GITHUB_WORKSPACE:/volume \ | |
--rm -t clux/muslrust:stable \ | |
sh -c "/volume/build-musl.sh" | |
- name: Archive production artifact | |
uses: actions/upload-artifact@v2 | |
with: | |
name: sirene | |
path: dist/sirene | |
- name: Caching Docker layers | |
if: github.event_name != 'pull_request' | |
uses: actions/cache@v2 | |
with: | |
path: /tmp/.buildx-cache | |
key: ${{ runner.os }}-buildx-${{ github.sha }} | |
restore-keys: | | |
${{ runner.os }}-buildx- | |
- name: Set up QEMU | |
if: github.event_name != 'pull_request' | |
uses: docker/setup-qemu-action@v1 | |
- name: Set up Docker Buildx | |
if: github.event_name != 'pull_request' | |
uses: docker/setup-buildx-action@v1 | |
with: | |
driver-opts: image=moby/buildkit:master | |
- name: Login to DockerHub | |
if: github.event_name != 'pull_request' | |
uses: docker/login-action@v1 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: Docker build and push | |
if: github.event_name != 'pull_request' | |
uses: docker/build-push-action@v2 | |
with: | |
context: ./dist | |
file: ./dist/Dockerfile | |
push: true | |
tags: ${{ steps.prep.outputs.tags }} | |
cache-from: type=local,src=/tmp/.buildx-cache | |
cache-to: type=local,dest=/tmp/.buildx-cache | |
clippy: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- run: rustup component add clippy | |
- uses: actions-rs/clippy-check@v1 | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
args: --all-features |