Skip to content

Commit

Permalink
add workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
elasticroentgen committed Sep 9, 2024
1 parent 4e14827 commit 7a69555
Show file tree
Hide file tree
Showing 2 changed files with 160 additions and 0 deletions.
86 changes: 86 additions & 0 deletions .github/workflows/build-cli.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
name: Build and Release .NET App

on:
push:
tags:
- 'v*'

jobs:
build:
runs-on: ubuntu-latest
defaults:
run:
shell: bash
working-directory: ./sherlog-cli
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Setup .NET Core
uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.0' # Specify your .NET version here

- name: Build self-contained binary for osx-arm64
run: dotnet publish -c Release -r osx-arm64 --self-contained true -p:PublishSingleFile=true -o ./publish/osx-arm64

- name: Build self-contained binary for osx-x64
run: dotnet publish -c Release -r osx-x64 --self-contained true -p:PublishSingleFile=true -o ./publish/osx-x64

- name: Build self-contained binary for linux-x64
run: dotnet publish -c Release -r linux-x64 --self-contained true -p:PublishSingleFile=true -o ./publish/linux-x64

- name: Build self-contained binary for linux-arm64
run: dotnet publish -c Release -r linux-arm64 --self-contained true -p:PublishSingleFile=true -o ./publish/linux-arm64

- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
draft: false
prerelease: false
body: "Release of version ${{ github.ref }}"

- name: Upload Release Asset osx-arm64
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./publish/osx-arm64/sherlog-cli
asset_name: sherlog-cli-osx-arm64
asset_content_type: application/octet-stream

- name: Upload Release Asset osx-x64
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./publish/osx-x64/sherlog-cli
asset_name: sherlog-cli-osx-x64
asset_content_type: application/octet-stream

- name: Upload Release Asset linux-x64
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./publish/linux-x64/sherlog-cli
asset_name: sherlog-cli-linux-x64
asset_content_type: application/octet-stream

- name: Upload Release Asset linux-arm64
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./publish/linux-arm64/sherlog-cli
asset_name: sherlog-cli-linux-arm64
asset_content_type: application/octet-stream
74 changes: 74 additions & 0 deletions .github/workflows/build-server.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
name: Build Server

# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.

on:
workflow_dispatch:
push:
branches: [ "main" ]
# Publish semver tags as releases.
tags: [ 'v*.*.*' ]
pull_request:
branches: [ "main" ]

env:
# Use docker.io for Docker Hub if empty
REGISTRY: ghcr.io
# github.repository as <account>/<repo>
IMAGE_NAME: ${{ github.repository }}


jobs:
build:
runs-on: ['self-hosted-ghr', 'size-s-x64']
permissions:
contents: read
packages: write
# This is used to complete the identity challenge
# with sigstore/fulcio when running outside of PRs.
id-token: write

steps:
- name: Checkout repository
uses: actions/checkout@v3

# Set up BuildKit Docker container builder to be able to build
# multi-platform images and export cache
# https://github.com/docker/setup-buildx-action
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@f95db51fddba0c2d1ec667646a06c2ce06100226 # v3.0.0

# Login against a Docker registry except on PR
# https://github.com/docker/login-action
- name: Log into registry ${{ env.REGISTRY }}
if: github.event_name != 'pull_request'
uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

# Extract metadata (tags, labels) for Docker
# https://github.com/docker/metadata-action
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@96383f45573cb7f253c731d3b3ab81c87ef81934 # v5.0.0
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

# Build and push Docker image with Buildx (don't push on PR)
# https://github.com/docker/build-push-action
- name: Build and push Docker image
id: build-and-push
uses: docker/build-push-action@v6
with:
context: ./Sherlog.Server
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max

0 comments on commit 7a69555

Please sign in to comment.