Skip to content

Commit

Permalink
feat(ci): Add basic (docker + rust + release) CI
Browse files Browse the repository at this point in the history
  • Loading branch information
flo-ride committed Oct 14, 2024
1 parent 08ea696 commit 2073737
Show file tree
Hide file tree
Showing 3 changed files with 138 additions and 0 deletions.
43 changes: 43 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Docker CI

on:
workflow_dispatch:
push:
branches:
- "master"
tags:
- "v*"
pull_request:
branches:
- "master"

env:
# github.repository as <account>/<repo>
IMAGE_NAME: ${{ github.repository }}

jobs:
docker_hub:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Login to Docker Hub
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: floride/scrounch_backend
- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=registry,ref=floride/scrounch_backend:latest
cache-to: type=inline
47 changes: 47 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Release CI

on:
push:
tags:
- "v*"

jobs:
build_and_tests:
uses: ./.github/workflows/rust.yml
release:
runs-on: ubuntu-latest
needs: build_and_tests
steps:
- uses: actions/checkout@v4
- name: Fetch tags
run: git fetch --tags --force
- name: Get current tag annotation
id: tag-data
uses: ericcornelissen/git-tag-annotation-action@v2
- name: Create GitHub release
uses: Roang-zero1/github-create-release-action@v3
with:
version_regex: ^v.*
release_text: ${{ steps.tag-data.outputs.git-tag-annotation }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- if: failure()
name: Delete tag
uses: prompt/actions-delete-tag@v1
add_binary:
needs: release
name: Release Binary ${{ matrix.target }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
target: [x86_64-pc-windows-gnu, x86_64-unknown-linux-musl]
steps:
- uses: actions/checkout@v4
- name: Compile and release
uses: rust-build/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
RUSTTARGET: ${{ matrix.target }}
EXTRA_FILES: "README.md LICENSE"
48 changes: 48 additions & 0 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Rust CI

on:
push:
branches: "*"
pull_request:
branches: "*"
workflow_call:

jobs:
build:
name: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions-rust-lang/setup-rust-toolchain@v1
- run: cargo check --verbose --workspace

test:
name: test
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@v4
- uses: actions-rust-lang/setup-rust-toolchain@v1
- run: cargo test --all-features --workspace

clippy:
name: linter
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@v4
- uses: actions-rust-lang/setup-rust-toolchain@v1
with:
components: clippy
- run: cargo clippy -- -D warnings

format:
name: format
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@v4
- uses: actions-rust-lang/setup-rust-toolchain@v1
with:
components: rustfmt
- run: cargo fmt -- --check

0 comments on commit 2073737

Please sign in to comment.