Attempt to port builds to GitHub Actions.

This commit is contained in:
Syfaro 2021-12-09 00:03:11 -05:00
parent de95393147
commit 9de76851bb
9 changed files with 194 additions and 169 deletions

187
.github/workflows/release.yml vendored Normal file
View File

@ -0,0 +1,187 @@
name: Release
on:
push:
env:
CARGO_TERM_COLOR: always
jobs:
release:
runs-on: ubuntu-20.04
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v2
- name: Cache target
uses: actions/cache@v2
with:
path: |
target/
key: ${{ runner.os }}-release-${{ hashFiles('Cargo.lock') }}
- name: Get stable toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
- name: Install dependencies
run: |
sudo apt-get update -y
sudo apt-get install -y libssl-dev pkg-config libavcodec-dev libavformat-dev libavutil-dev libavdevice-dev clang llvm python3 python3-pip
- name: Build binaries
uses: actions-rs/cargo@v1
with:
command: build
args: --release
- name: Move binaries
run: |
mv target/release/fuzzysearch fuzzysearch/fuzzysearch
mv target/release/fuzzysearch-webhook fuzzysearch-webhook/fuzzysearch-webhook
mv target/release/fuzzysearch-refresh fuzzysearch-refresh/fuzzysearch-refresh
mv target/release/fuzzysearch-hash-input fuzzysearch-hash-input/fuzzysearch-hash-input
mv target/release/fuzzysearch-ingest-e621 fuzzysearch-ingest-e621/fuzzysearch-ingest-e621
mv target/release/fuzzysearch-ingest-furaffinity fuzzysearch-ingest-furaffinity/fuzzysearch-ingest-furaffinity
mv target/release/fuzzysearch-ingest-weasyl fuzzysearch-ingest-weasyl/fuzzysearch-ingest-weasyl
- name: Upload binaries
uses: actions/upload-artifact@v2
with:
name: binaries
path: |
fuzzysearch/fuzzysearch
fuzzysearch-webhook/fuzzysearch-webhook
fuzzysearch-refresh/fuzzysearch-refresh
fuzzysearch-hash-input/fuzzysearch-hash-input
fuzzysearch-ingest-e621/fuzzysearch-ingest-e621
fuzzysearch-ingest-furaffinity/fuzzysearch-ingest-furaffinity
fuzzysearch-ingest-weasyl/fuzzysearch-ingest-weasyl
- name: Login to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract FuzzySearch metadata for Docker
id: meta-fuzzysearch
uses: docker/metadata-action@v3
with:
images: ghcr.io/syfaro/fuzzysearch
- name: Extract FuzzySearch Webhook metadata for Docker
id: meta-fuzzysearch-webhook
uses: docker/metadata-action@v3
with:
images: ghcr.io/syfaro/fuzzysearch-webhook
- name: Extract FuzzySearch refresh metadata for Docker
id: meta-fuzzysearch-refresh
uses: docker/metadata-action@v3
with:
images: ghcr.io/syfaro/fuzzysearch-refresh
- name: Extract FuzzySearch hash input metadata for Docker
id: meta-fuzzysearch-hash-input
uses: docker/metadata-action@v3
with:
images: ghcr.io/syfaro/fuzzysearch-hash-input
- name: Extract FuzzySearch ingest e621 metadata for Docker
id: meta-fuzzysearch-ingest-e621
uses: docker/metadata-action@v3
with:
images: ghcr.io/syfaro/fuzzysearch-ingest-e621
- name: Extract FuzzySearch ingest FurAffinity metadata for Docker
id: meta-fuzzysearch-ingest-furaffinity
uses: docker/metadata-action@v3
with:
images: ghcr.io/syfaro/fuzzysearch-ingest-furaffinity
- name: Extract FuzzySearch ingest Weasyl metadata for Docker
id: meta-fuzzysearch-ingest-weasyl
uses: docker/metadata-action@v3
with:
images: ghcr.io/syfaro/fuzzysearch-ingest-weasyl
- name: Build and push FuzzySearch Docker image
uses: docker/build-push-action@v2
with:
context: .
push: true
tags: ${{ steps.meta-fuzzysearch.outputs.tags }}
labels: ${{ steps.meta-fuzzysearch.outputs.labels }}
file: fuzzysearch/Dockerfile
- name: Build and push FuzzySearch Webhook Docker image
uses: docker/build-push-action@v2
with:
context: .
push: true
tags: ${{ steps.meta-fuzzysearch-webhook.outputs.tags }}
labels: ${{ steps.meta-fuzzysearch-webhook.outputs.labels }}
file: fuzzysearch-webhook/Dockerfile
- name: Build and push FuzzySearch hash input Docker image
uses: docker/build-push-action@v2
with:
context: .
push: true
tags: ${{ steps.meta-fuzzysearch-hash-input.outputs.tags }}
labels: ${{ steps.meta-fuzzysearch-hash-input.outputs.labels }}
file: fuzzysearch-hash-input/Dockerfile
- name: Build and push FuzzySearch refresh Docker image
uses: docker/build-push-action@v2
with:
context: .
push: true
tags: ${{ steps.meta-fuzzysearch-refresh.outputs.tags }}
labels: ${{ steps.meta-fuzzysearch-refresh.outputs.labels }}
file: fuzzysearch-refresh/Dockerfile
- name: Build and push FuzzySearch ingest e621 Docker image
uses: docker/build-push-action@v2
with:
context: .
push: true
tags: ${{ steps.meta-fuzzysearch-ingest-e621.outputs.tags }}
labels: ${{ steps.meta-fuzzysearch-ingest-e621.outputs.labels }}
file: fuzzysearch-ingest-e621/Dockerfile
- name: Build and push FuzzySearch ingest FurAffinity Docker image
uses: docker/build-push-action@v2
with:
context: .
push: true
tags: ${{ steps.meta-fuzzysearch-ingest-furaffinity.outputs.tags }}
labels: ${{ steps.meta-fuzzysearch-ingest-furaffinity.outputs.labels }}
file: fuzzysearch-ingest-furaffinity/Dockerfile
- name: Build and push FuzzySearch ingest Weasyl Docker image
uses: docker/build-push-action@v2
with:
context: .
push: true
tags: ${{ steps.meta-fuzzysearch-ingest-weasyl.outputs.tags }}
labels: ${{ steps.meta-fuzzysearch-ingest-weasyl.outputs.labels }}
file: fuzzysearch-ingest-weasyl/Dockerfile
sourcegraph:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Generate LSIF data
uses: sourcegraph/lsif-rust-action@main
- name: Upload LSIF data
uses: sourcegraph/lsif-upload-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}

View File

@ -1,162 +0,0 @@
stages:
- test
- build
- image
variables:
CARGO_HOME: "$CI_PROJECT_DIR/.cargo"
SQLX_OFFLINE: "true"
# Cache should only be updated once, default to pull only
cache: &global_cache
key:
files:
- Cargo.lock
paths:
- .cargo/
policy: pull
# Run tests on current stable Rust version
test:latest: &base_test
image: rust:1.54-slim-buster
stage: test
cache:
<<: *global_cache
policy: pull-push
before_script:
- apt-get update -y
- apt-get install -y libssl-dev pkg-config libavcodec-dev libavformat-dev libavutil-dev libavdevice-dev clang llvm python3 python3-pip
script:
# Build, test, and show stats
- cargo build --verbose
- cargo test --verbose
# Same as above, but nightly Rust
test:nightly:
<<: *base_test
image: rustlang/rust:nightly-slim
allow_failure: true
build:api: &base_build
<<: *base_test
stage: build
cache:
<<: *global_cache
policy: pull
needs: ['test:latest']
artifacts:
expire_in: 1 day
paths:
- ./fuzzysearch/fuzzysearch
script:
- cargo build --verbose --release --bin fuzzysearch
- mv ./target/release/fuzzysearch ./fuzzysearch/fuzzysearch
build:webhook:
<<: *base_build
artifacts:
expire_in: 1 day
paths:
- ./fuzzysearch-webhook/fuzzysearch-webhook
script:
- cargo build --verbose --release --bin fuzzysearch-webhook
- mv ./target/release/fuzzysearch-webhook ./fuzzysearch-webhook/fuzzysearch-webhook
build:hash-input:
<<: *base_build
artifacts:
expire_in: 1 day
paths:
- ./fuzzysearch-hash-input/fuzzysearch-hash-input
script:
- cargo build --verbose --release --bin fuzzysearch-hash-input
- mv ./target/release/fuzzysearch-hash-input ./fuzzysearch-hash-input/fuzzysearch-hash-input
build:ingest-e621:
<<: *base_build
artifacts:
expire_in: 1 day
paths:
- ./fuzzysearch-ingest-e621/fuzzysearch-ingest-e621
script:
- cargo build --verbose --release --bin fuzzysearch-ingest-e621
- mv ./target/release/fuzzysearch-ingest-e621 ./fuzzysearch-ingest-e621/fuzzysearch-ingest-e621
build:ingest-furaffinity:
<<: *base_build
artifacts:
expire_in: 1 day
paths:
- ./fuzzysearch-ingest-furaffinity/fuzzysearch-ingest-furaffinity
script:
- cargo build --verbose --release --bin fuzzysearch-ingest-furaffinity
- mv ./target/release/fuzzysearch-ingest-furaffinity ./fuzzysearch-ingest-furaffinity/fuzzysearch-ingest-furaffinity
build:ingest-weasyl:
<<: *base_build
artifacts:
expire_in: 1 day
paths:
- ./fuzzysearch-ingest-weasyl/fuzzysearch-ingest-weasyl
script:
- cargo build --verbose --release --bin fuzzysearch-ingest-weasyl
- mv ./target/release/fuzzysearch-ingest-weasyl ./fuzzysearch-ingest-weasyl/fuzzysearch-ingest-weasyl
build:refresh:
<<: *base_build
artifacts:
expire_in: 1 day
paths:
- ./fuzzysearch-refresh/fuzzysearch-refresh
script:
- cargo build --verbose --release --bin fuzzysearch-refresh
- mv ./target/release/fuzzysearch-refresh ./fuzzysearch-refresh/fuzzysearch-refresh
images:api: &base_images
stage: image
image:
name: gcr.io/kaniko-project/executor:debug
entrypoint: [""]
cache: {}
before_script:
- mkdir -p /kaniko/.docker
- echo "{\"auths\":{\"$CI_REGISTRY\":{\"auth\":\"$(echo -n ${CI_REGISTRY_USER}:${CI_REGISTRY_PASSWORD} | base64)\"}}}" > /kaniko/.docker/config.json
needs: ['build:api']
script:
- /kaniko/executor --context $CI_PROJECT_DIR --dockerfile $CI_PROJECT_DIR/fuzzysearch/Dockerfile --destination $CI_REGISTRY_IMAGE/api:$CI_COMMIT_SHA --destination $CI_REGISTRY_IMAGE/api:latest --cache=true
images:webhook:
<<: *base_images
needs: ['build:webhook']
script:
- /kaniko/executor --context $CI_PROJECT_DIR --dockerfile $CI_PROJECT_DIR/fuzzysearch-webhook/Dockerfile --destination $CI_REGISTRY_IMAGE/webhook:$CI_COMMIT_SHA --destination $CI_REGISTRY_IMAGE/webhook:latest --cache=true
images:hash-input:
<<: *base_images
needs: ['build:hash-input']
script:
- /kaniko/executor --context $CI_PROJECT_DIR --dockerfile $CI_PROJECT_DIR/fuzzysearch-hash-input/Dockerfile --destination $CI_REGISTRY_IMAGE/hash-input:$CI_COMMIT_SHA --destination $CI_REGISTRY_IMAGE/hash-input:latest --cache=true
images:ingest-e621:
<<: *base_images
needs: ['build:ingest-e621']
script:
- /kaniko/executor --context $CI_PROJECT_DIR --dockerfile $CI_PROJECT_DIR/fuzzysearch-ingest-e621/Dockerfile --destination $CI_REGISTRY_IMAGE/ingest-e621:$CI_COMMIT_SHA --destination $CI_REGISTRY_IMAGE/ingest-e621:latest --cache=true
images:ingest-furaffinity:
<<: *base_images
needs: ['build:ingest-furaffinity']
script:
- /kaniko/executor --context $CI_PROJECT_DIR --dockerfile $CI_PROJECT_DIR/fuzzysearch-ingest-furaffinity/Dockerfile --destination $CI_REGISTRY_IMAGE/ingest-furaffinity:$CI_COMMIT_SHA --destination $CI_REGISTRY_IMAGE/ingest-furaffinity:latest --cache=true
images:ingest-weasyl:
<<: *base_images
needs: ['build:ingest-weasyl']
script:
- /kaniko/executor --context $CI_PROJECT_DIR --dockerfile $CI_PROJECT_DIR/fuzzysearch-ingest-weasyl/Dockerfile --destination $CI_REGISTRY_IMAGE/ingest-weasyl:$CI_COMMIT_SHA --destination $CI_REGISTRY_IMAGE/ingest-weasyl:latest --cache=true
images:refresh:
<<: *base_images
needs: ['build:refresh']
script:
- /kaniko/executor --context $CI_PROJECT_DIR --dockerfile $CI_PROJECT_DIR/fuzzysearch-refresh/Dockerfile --destination $CI_REGISTRY_IMAGE/refresh:$CI_COMMIT_SHA --destination $CI_REGISTRY_IMAGE/refresh:latest --cache=true

View File

@ -1,4 +1,4 @@
FROM debian:buster-slim
FROM ubuntu:20.04
RUN apt-get update -y && apt-get install -y openssl ca-certificates && rm -rf /var/lib/apt/lists/*
COPY ./fuzzysearch-hash-input/fuzzysearch-hash-input /bin/fuzzysearch-hash-input
CMD ["/bin/fuzzysearch-hash-input"]

View File

@ -1,4 +1,4 @@
FROM debian:buster-slim
FROM ubuntu:20.04
EXPOSE 8080
ENV METRICS_HOST=0.0.0.0:8080
RUN apt-get update -y && apt-get install -y openssl ca-certificates && rm -rf /var/lib/apt/lists/*

View File

@ -1,4 +1,4 @@
FROM debian:buster-slim
FROM ubuntu:20.04
RUN apt-get update -y && \
apt-get install -y openssl ca-certificates && \
rm -rf /var/lib/apt/lists/*

View File

@ -1,4 +1,4 @@
FROM debian:buster-slim
FROM ubuntu:20.04
RUN apt-get update -y && apt-get install -y openssl ca-certificates && rm -rf /var/lib/apt/lists/*
COPY ./fuzzysearch-ingest-weasyl/fuzzysearch-ingest-weasyl /bin/fuzzysearch-ingest-weasyl
CMD ["/bin/fuzzysearch-ingest-weasyl"]

View File

@ -1,4 +1,4 @@
FROM debian:buster-slim
FROM ubuntu:20.04
RUN apt-get update -y && apt-get install -y openssl ca-certificates && rm -rf /var/lib/apt/lists/*
COPY ./fuzzysearch-refresh/fuzzysearch-refresh /bin/fuzzysearch-refresh
CMD ["/bin/fuzzysearch-refresh"]

View File

@ -1,4 +1,4 @@
FROM debian:buster-slim
FROM ubuntu:20.04
RUN apt-get update -y && apt-get install -y openssl ca-certificates && rm -rf /var/lib/apt/lists/*
COPY ./fuzzysearch-webhook/fuzzysearch-webhook /bin/fuzzysearch-webhook
CMD ["/bin/fuzzysearch-webhook"]

View File

@ -1,4 +1,4 @@
FROM debian:buster-slim
FROM ubuntu:20.04
EXPOSE 8080 8081
ENV METRICS_HOST=0.0.0.0:8081
RUN apt-get update -y && apt-get install -y --no-install-recommends openssl ca-certificates ffmpeg && rm -rf /var/lib/apt/lists/*