Skip to content

Commit

Permalink
feat(ci/cd) adding new pipelines
Browse files Browse the repository at this point in the history
pipelines now include:
* docker build
* ci check
* version check
* biweekly release
  • Loading branch information
uhryniuk committed Oct 11, 2024
1 parent ef792d2 commit ac8e1c5
Show file tree
Hide file tree
Showing 6 changed files with 153 additions and 59 deletions.
49 changes: 49 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: ci

on:
push:
branches:
- main
pull_request:
branches:
- main
workflow_dispatch:

env:
CARGO_TERM_COLOR: always

jobs:
build-and-test:
runs-on: ubuntu-latest

steps:
- name: checkout code
uses: actions/checkout@v3

- name: set up Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
override: true

- name: install dependencies
run: |
rustup component add rustfmt clippy
cargo install cargo-audit
- name: check formatting
run: cargo fmt -- --check

- name: run linting
run: cargo clippy -- -D warnings

- name: audit for vulnerabilities
run: cargo audit

- name: build project
run: cargo build --release

- name: run tests
run: cargo test

13 changes: 9 additions & 4 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Build and Push Docker Image
name: docker

on:
workflow_dispatch:
Expand All @@ -21,6 +21,8 @@ jobs:
-
name: Set up QEMU
uses: docker/setup-qemu-action@v3
with:
platforms: linux/amd64,linux/arm64
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
Expand All @@ -31,10 +33,13 @@ jobs:
username: ${{ secrets.DOCKER_USERNAME}}
password: ${{ secrets.DOCKER_PASSWORD}}
-
name: Build and push
name: Build and push versioned
uses: docker/build-push-action@v6
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: uhryniuk/tally:${{ env.VERSION }}

tags: |
uhryniuk/tally:${{ env.VERSION }}
uhryniuk/tally:latest
54 changes: 0 additions & 54 deletions .github/workflows/lint-build-test.yml

This file was deleted.

66 changes: 66 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# Creates tag, release page and uploads release binary to it.
# TODO refactor this with other pipelines.
name: auto-release

on:
schedule:
- cron: '0 0 */14 * *' # Runs every 14 days at midnight UTC
workflow_dispatch:

jobs:
create-tag-release:
runs-on: ubuntu-latest

steps:
# Step 1: Check out the code
- name: Checkout code
uses: actions/checkout@v3

# Step 2: Calculate the next version tag
- name: Calculate next tag
id: tag_version
run: |
# Fetch existing tags
git fetch --tags
# Get the latest tag and calculate the new version
latest_tag=$(git describe --tags --abbrev=0)
tag_version=${latest_tag:-"v0.0.0"}
# Increment the patch version (you can adjust this to major/minor)
new_version=$(echo $tag_version | awk -F. '{$NF+=1; OFS="."; print $0}')
echo "New version: $new_version"
# Set output for other steps
echo "::set-output name=tag::$new_version"
# Step 3: Build your project (replace with your build process)
- name: Build the project
run: |
# Example build steps (adjust based on your project)
# For example, for Rust:
cargo build --release
# Step 4: Compress build output (optional)
- name: Compress artifacts
run: |
tar -czvf build_artifacts.tar.gz ./target/release/
# Step 5: Create the new tag
- name: Create new tag
run: |
git tag ${{ steps.tag_version.outputs.tag }}
git push origin ${{ steps.tag_version.outputs.tag }}
# Step 6: Upload the release assets (artifacts)
- name: Create GitHub Release and Upload Artifacts
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.tag_version.outputs.tag }}
release_name: "Release ${{ steps.tag_version.outputs.tag }}"
body: "Automated release for version ${{ steps.tag_version.outputs.tag }}"
draft: false
prerelease: false
files: build_artifacts.tar.gz # Upload the compressed build artifacts
28 changes: 28 additions & 0 deletions .github/workflows/version-check.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: version-check

on:
pull_request:
branches:
- main
workflow_dispatch:

jobs:
build-and-test:
runs-on: ubuntu-latest

steps:
- name: checkout code
uses: actions/checkout@v3

- name: ensure version has been incremented
run: |
VERSION_BASE=$(git show origin/main:Cargo.toml | grep '^version = ' | awk '{ print $3 }' | tr -d '"')
VERSION_HEAD=$(grep '^version = ' Cargo.toml | awk '{ print $3 }' | tr -d '"')
echo "Base version: $VERSION_BASE"
echo "Head version: $VERSION_HEAD"
if [ "$VERSION_BASE" = "$VERSION_HEAD" ]; then
echo "Error: Cargo.toml version has not been incremented!"
exit 1
else
echo "Version has been incremented."
fi
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "tally-cli"
version = "0.1.2"
version = "0.1.3"
authors = ["Dylan Uhryniuk <[email protected]>"]
license = "MIT"
repository = "https://github.com/uhryniuk/tally"
Expand Down

0 comments on commit ac8e1c5

Please sign in to comment.