ci: Create GitHub Workflow (#9)

Add support for building, tagging, and releasing via CICD

---------

Co-authored-by: Gerald Pinder <gmpinder@gmail.com>
This commit is contained in:
N16hth4wk 2024-01-23 19:07:48 -06:00 committed by GitHub
parent 6fffe1286e
commit 99649d2d88
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 136 additions and 13 deletions

34
.github/workflows/build.yml vendored Normal file
View file

@ -0,0 +1,34 @@
name: Earthly +build
on:
merge_group:
pull_request:
push:
branches:
- main
env:
FORCE_COLOR: 1
jobs:
build:
timeout-minutes: 30
runs-on: ubuntu-latest
steps:
- uses: earthly/actions-setup@v1
with:
use-cache: true
version: v0.8.0
# Pulling rust toolchain & install linux dependencies
- uses: dtolnay/rust-toolchain@stable
# Setup repo and add caching
- uses: actions/checkout@v4
- name: Docker Login
run: docker login ghcr.io -u ${{ github.actor }} -p ${{ secrets.GITHUB_TOKEN }}
- name: Run build
run: earthly --push --ci -P +all

46
.github/workflows/release.yml vendored Normal file
View file

@ -0,0 +1,46 @@
name: Open a release PR
# how to trigger: https://docs.github.com/en/actions/managing-workflow-runs/manually-running-a-workflow
on:
workflow_dispatch:
inputs:
version:
description: Version to release
required: true
type: string
env:
CARGO_TERM_COLOR: always
jobs:
release-pr:
runs-on: ubuntu-latest
permissions:
id-token: write # Enable OIDC
contents: write
pull-requests: write
steps:
- uses: actions/checkout@v4
- uses: actions/cache@v4
with:
path: |
target/
~/.cargo/bin/
~/.cargo/git/db/
~/.cargo/registry/index/
~/.cargo/registry/cache/
key: ${{ runner.os }}-cargo-build-stable-${{ hashFiles('**/Cargo.toml') }}
- uses: chainguard-dev/actions/setup-gitsign@main
# Pulling rust toolchain & install linux dependencies
- uses: dtolnay/rust-toolchain@stable
- name: Install cargo-release
uses: taiki-e/install-action@v1
with:
tool: cargo-smart-release
- name: Release
run: cargo smart-release -ue

53
.github/workflows/tag.yml vendored Normal file
View file

@ -0,0 +1,53 @@
name: Earthly +tag
on:
push:
tags:
- "v*.*.*"
env:
FORCE_COLOR: 1
jobs:
tag:
timeout-minutes: 60
runs-on: ubuntu-latest
steps:
# Setup repo and add caching
- uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true
#Deps
- name: Set up Earthly
uses: earthly/actions-setup@v1
with:
version: v0.8.0
use-cache: true
- name: Set up Python
uses: actions/setup-python@v5
- name: Add tomlq
run: pip install tomlq
- name: Docker Login
run: docker login ghcr.io -u ${{ github.actor }} -p ${{ secrets.GITHUB_TOKEN }}
- name: Fetch tags
run: git fetch --tags
- name: Get Latest Tag
id: latest_tag
run: echo "LATEST_TAG=$(git describe --tags `git rev-list --tags --max-count=1`)" >> $GITHUB_OUTPUT
- name: Check Cargo Version
id: cargo_version
run: echo "CARGO_PACKAGE_VERSION=$(tomlq '.package.version' $PWD/Cargo.toml | sed 's/\"//g')" >> $GITHUB_OUTPUT
- name: Run build
env:
TAG: ${{ steps.latest_tag.outputs.LATEST_TAG }}
LATEST: ${{ steps.cargo_version.outputs.CARGO_PACKAGE_VERSION == steps.latest_tag.outputs.LATEST_TAG }}
run: earthly --push --ci -P +all --TAG=${{ env.TAG }} --LATEST=${{ env.LATEST }}

View file

@ -1,6 +0,0 @@
variables:
INTEGRATION_TESTS: 1
include:
- project: wunker-bunker/ci-pipelines
file: cargo-earthly.yml

View file

@ -1,12 +1,8 @@
VERSION \
--global-cache \
--use-function-keyword \
--arg-scope-and-set \
0.7
VERSION 0.8
IMPORT gitlab.com/wunker-bunker/ci-pipelines/earthly/cargo AS cargo
IMPORT github.com/blue-build/earthly-lib/cargo AS cargo
ARG --global IMAGE=registry.gitlab.com/wunker-bunker/blue-build
ARG --global IMAGE=ghcr.io/blue-build/cli
all:
BUILD +default