Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: CI

on:
pull_request:
branches: [main]

jobs:
test:
name: Test (${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]

steps:
- uses: actions/checkout@v4

- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.0.x'

- name: Restore dependencies
run: dotnet restore

- name: Build
run: dotnet build --no-restore

- name: Test
run: dotnet test --no-build --verbosity normal
150 changes: 150 additions & 0 deletions .github/workflows/release-cli.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
name: Release CLI

on:
workflow_dispatch:

jobs:
validate:
name: Validate version
runs-on: ubuntu-latest
outputs:
version: ${{ steps.read_version.outputs.version }}
steps:
- uses: actions/checkout@v4

- name: Read version from semver.txt
id: read_version
run: |
version=$(tr -d '[:space:]' < src/CoderPatros.Tea.Cli/semver.txt)
echo "version=$version" >> "$GITHUB_OUTPUT"

- name: Validate semver format
run: |
if ! echo "${{ steps.read_version.outputs.version }}" | grep -qE '^[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9.]+)?(\+[a-zA-Z0-9.]+)?$'; then
echo "::error::Version '${{ steps.read_version.outputs.version }}' is not valid semver"
exit 1
fi

- name: Check tag does not exist
run: |
if git ls-remote --tags https://github.com/${{ github.repository }} | grep -q "refs/tags/cli/v${{ steps.read_version.outputs.version }}$"; then
echo "::error::Tag cli/v${{ steps.read_version.outputs.version }} already exists"
exit 1
fi

test:
name: Test (${{ matrix.os }})
needs: validate
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
steps:
- uses: actions/checkout@v4

- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.0.x'

- name: Restore dependencies
run: dotnet restore

- name: Build
run: dotnet build --no-restore

- name: Test
run: dotnet test --no-build --verbosity normal

build:
name: Build (${{ matrix.rid }})
needs: [validate, test]
runs-on: ${{ matrix.runner }}
env:
VERSION: ${{ needs.validate.outputs.version }}
strategy:
fail-fast: false
matrix:
include:
- rid: linux-x64
runner: ubuntu-latest
archive: tar.gz
- rid: linux-arm64
runner: ubuntu-latest
archive: tar.gz
- rid: osx-x64
runner: macos-latest
archive: tar.gz
- rid: osx-arm64
runner: macos-latest
archive: tar.gz
- rid: win-x64
runner: windows-latest
archive: zip
- rid: win-arm64
runner: windows-latest
archive: zip
steps:
- uses: actions/checkout@v4

- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.0.x'

- name: Publish
run: >
dotnet publish src/CoderPatros.Tea.Cli/CoderPatros.Tea.Cli.csproj
-c Release
-r ${{ matrix.rid }}
--self-contained true
-p:PublishSingleFile=true
-p:DebugType=none
-p:Version=${{ env.VERSION }}
-o ./publish

- name: Archive (tar.gz)
if: matrix.archive == 'tar.gz'
run: tar -czf tea-cli-v${{ env.VERSION }}-${{ matrix.rid }}.tar.gz -C ./publish .

- name: Archive (zip)
if: matrix.archive == 'zip'
shell: pwsh
run: Compress-Archive -Path ./publish/* -DestinationPath tea-cli-v${{ env.VERSION }}-${{ matrix.rid }}.zip

- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: tea-cli-v${{ env.VERSION }}-${{ matrix.rid }}
path: tea-cli-v${{ env.VERSION }}-${{ matrix.rid }}.${{ matrix.archive }}

release:
name: Release
needs: [validate, build]
runs-on: ubuntu-latest
permissions:
contents: write
env:
VERSION: ${{ needs.validate.outputs.version }}
steps:
- uses: actions/checkout@v4

- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: ./artifacts
merge-multiple: true

- name: Create and push tag
run: |
git tag "cli/v${{ env.VERSION }}"
git push origin "cli/v${{ env.VERSION }}"

- name: Create GitHub release
uses: softprops/action-gh-release@v2
with:
tag_name: cli/v${{ env.VERSION }}
name: CLI v${{ env.VERSION }}
generate_release_notes: true
files: ./artifacts/*
96 changes: 96 additions & 0 deletions .github/workflows/release-client.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
name: Release Client Libraries

on:
workflow_dispatch:

jobs:
validate:
name: Validate version
runs-on: ubuntu-latest
outputs:
version: ${{ steps.read_version.outputs.version }}
steps:
- uses: actions/checkout@v4

- name: Read version from semver.txt
id: read_version
run: |
version=$(tr -d '[:space:]' < src/CoderPatros.Tea.Client/semver.txt)
echo "version=$version" >> "$GITHUB_OUTPUT"

- name: Validate semver format
run: |
if ! echo "${{ steps.read_version.outputs.version }}" | grep -qE '^[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9.]+)?(\+[a-zA-Z0-9.]+)?$'; then
echo "::error::Version '${{ steps.read_version.outputs.version }}' is not valid semver"
exit 1
fi

- name: Check tag does not exist
run: |
if git ls-remote --tags https://github.com/${{ github.repository }} | grep -q "refs/tags/client/v${{ steps.read_version.outputs.version }}$"; then
echo "::error::Tag client/v${{ steps.read_version.outputs.version }} already exists"
exit 1
fi

test:
name: Test (${{ matrix.os }})
needs: validate
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
steps:
- uses: actions/checkout@v4

- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.0.x'

- name: Restore dependencies
run: dotnet restore

- name: Build
run: dotnet build --no-restore

- name: Test
run: dotnet test --no-build --verbosity normal

release:
name: Release
needs: [validate, test]
runs-on: ubuntu-latest
permissions:
contents: write
env:
VERSION: ${{ needs.validate.outputs.version }}
steps:
- uses: actions/checkout@v4

- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.0.x'

- name: Pack Client
run: dotnet pack src/CoderPatros.Tea.Client/CoderPatros.Tea.Client.csproj -c Release -p:Version=${{ env.VERSION }} -o ./artifacts

- name: Pack Client DI Extensions
run: dotnet pack src/CoderPatros.Tea.Client.Extensions.DependencyInjection/CoderPatros.Tea.Client.Extensions.DependencyInjection.csproj -c Release -p:Version=${{ env.VERSION }} -o ./artifacts

- name: Push to NuGet
run: dotnet nuget push ./artifacts/*.nupkg --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json

- name: Create and push tag
run: |
git tag "client/v${{ env.VERSION }}"
git push origin "client/v${{ env.VERSION }}"

- name: Create GitHub release
uses: softprops/action-gh-release@v2
with:
tag_name: client/v${{ env.VERSION }}
name: Client Libraries v${{ env.VERSION }}
generate_release_notes: true
files: ./artifacts/*.nupkg
101 changes: 101 additions & 0 deletions .github/workflows/release-web.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
name: Release Web

on:
workflow_dispatch:

jobs:
validate:
name: Validate version
runs-on: ubuntu-latest
outputs:
version: ${{ steps.read_version.outputs.version }}
steps:
- uses: actions/checkout@v4

- name: Read version from semver.txt
id: read_version
run: |
version=$(tr -d '[:space:]' < src/CoderPatros.Tea.Web/semver.txt)
echo "version=$version" >> "$GITHUB_OUTPUT"

- name: Validate semver format
run: |
if ! echo "${{ steps.read_version.outputs.version }}" | grep -qE '^[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9.]+)?(\+[a-zA-Z0-9.]+)?$'; then
echo "::error::Version '${{ steps.read_version.outputs.version }}' is not valid semver"
exit 1
fi

- name: Check tag does not exist
run: |
if git ls-remote --tags https://github.com/${{ github.repository }} | grep -q "refs/tags/web/v${{ steps.read_version.outputs.version }}$"; then
echo "::error::Tag web/v${{ steps.read_version.outputs.version }} already exists"
exit 1
fi

test:
name: Test (${{ matrix.os }})
needs: validate
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
steps:
- uses: actions/checkout@v4

- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.0.x'

- name: Restore dependencies
run: dotnet restore

- name: Build
run: dotnet build --no-restore

- name: Test
run: dotnet test --no-build --verbosity normal

release:
name: Release
needs: [validate, test]
runs-on: ubuntu-latest
permissions:
contents: write
env:
VERSION: ${{ needs.validate.outputs.version }}
steps:
- uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
context: .
file: src/CoderPatros.Tea.Web/Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: |
coderpatros/tea-web:${{ env.VERSION }}
coderpatros/tea-web:latest

- name: Create and push tag
run: |
git tag "web/v${{ env.VERSION }}"
git push origin "web/v${{ env.VERSION }}"

- name: Create GitHub release
uses: softprops/action-gh-release@v2
with:
tag_name: web/v${{ env.VERSION }}
name: Web v${{ env.VERSION }}
generate_release_notes: true
1 change: 1 addition & 0 deletions src/CoderPatros.Tea.Cli/semver.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.0.1
1 change: 1 addition & 0 deletions src/CoderPatros.Tea.Client/semver.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.0.1
9 changes: 9 additions & 0 deletions src/CoderPatros.Tea.Web/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
WORKDIR /src
COPY . .
RUN dotnet publish src/CoderPatros.Tea.Web/CoderPatros.Tea.Web.csproj -c Release -o /app/publish

FROM mcr.microsoft.com/dotnet/aspnet:8.0
WORKDIR /app
COPY --from=build /app/publish .
ENTRYPOINT ["dotnet", "CoderPatros.Tea.Web.dll"]
1 change: 1 addition & 0 deletions src/CoderPatros.Tea.Web/semver.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.0.1