diff --git a/.github/workflows/build-cli.yaml b/.github/workflows/build-cli.yaml new file mode 100644 index 0000000..688b4cb --- /dev/null +++ b/.github/workflows/build-cli.yaml @@ -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 diff --git a/.github/workflows/build-server.yaml b/.github/workflows/build-server.yaml new file mode 100644 index 0000000..42ceb17 --- /dev/null +++ b/.github/workflows/build-server.yaml @@ -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 / + 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 +