Skip to content

Commit

Permalink
WIP: Working on build and publish pipeline (#5)
Browse files Browse the repository at this point in the history
* WIP: Working on build and publish pipeline
  • Loading branch information
erikbra authored Aug 2, 2023
1 parent f9928c7 commit b07e886
Show file tree
Hide file tree
Showing 5 changed files with 276 additions and 3 deletions.
11 changes: 11 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "daily"

- package-ecosystem: "nuget"
directory: "/"
schedule:
interval: "daily"
262 changes: 262 additions & 0 deletions .github/workflows/build-and-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,262 @@
# Heavyweight build and test
name: Build and Publish

on:
push:
branches:
- main
paths-ignore:
- docs/
workflow_dispatch:

jobs:
set-version-number:
name: Set version number
runs-on: ubuntu-latest
outputs:
nuGetVersion: ${{ steps.gitversion.outputs.nuGetVersionV2 }}
semVer: ${{ steps.gitversion.outputs.fullSemVer }}
#is-release: ${{ steps.gitversion.outputs.CommitsSinceVersionSource == 0 }}
is-release: 'true'

steps:
- name: Setup .NET 8
uses: actions/setup-dotnet@v3
with:
dotnet-version: 8.0.x
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Install GitVersion
uses: gittools/actions/gitversion/setup@v0.10.2
with:
versionSpec: '5.x'
- name: Determine Version
id: gitversion
uses: gittools/actions/gitversion/execute@v0.10.2

build-netcore-tool:
needs: set-version-number
name: Build .NET Core (global) tool

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Setup .NET 8
uses: actions/setup-dotnet@v3
with:
dotnet-version: 8.0.x
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet pack ./smink/smink.csproj -c release -p:PackAsTool=true -p:PackageOutputPath=/tmp/smink/nupkg
env:
VERSION: ${{ needs.set-version-number.outputs.nuGetVersion }}

- name: Upload published tool artifact
uses: actions/upload-artifact@v3
if: ${{ needs.set-version-number.outputs.is-release == 'true' }}
with:
name: smink-dotnet-tool-${{ needs.set-version-number.outputs.nuGetVersion }}
path: /tmp/smink/nupkg/*

# - name: Push to Nuget.org
# if: ${{ needs.set-version-number.outputs.is-release == 'true' }}
# run: dotnet nuget push /tmp/smink/nupkg/*.nupkg --source https://api.nuget.org/v3/index.json --api-key ${{secrets.NUGET_ORG_KEY}} --skip-duplicate

build-standalone:
name: Build
needs: set-version-number

runs-on: ubuntu-latest
strategy:
matrix:
arch: [ "win-x64", "win-x86", "win-arm", "win-arm64",
"alpine-x64", "linux-x64", "linux-arm", "linux-arm64",
"osx-x64", "osx.11.0-x64", "osx.11.0-arm64", "osx.12-x64", "osx.12-arm64", "osx.13-x64", "osx.13-arm64"
]

steps:
- uses: actions/checkout@v3
- name: Setup .NET 8
uses: actions/setup-dotnet@v3
with:
dotnet-version: 8.0.x

- name: Publish self-contained ${{ matrix.arch }}
run: dotnet publish ./smink/smink.csproj -r ${{ matrix.arch }} -c release --self-contained -p:SelfContained=true -o ./publish/${{ matrix.arch }}/self-contained
env:
VERSION: ${{ needs.set-version-number.outputs.nuGetVersion }}

- name: Upload self-contained ${{ matrix.arch }}
if: ${{ needs.set-version-number.outputs.is-release == 'true' }}
uses: actions/upload-artifact@v3
with:
name: smink-${{ matrix.arch }}-self-contained-${{ needs.set-version-number.outputs.nuGetVersion }}
path: ./publish/${{ matrix.arch }}/self-contained/*


# build-msi:
# name: Build MSI
# needs:
# - set-version-number
# - build-standalone
# runs-on: windows-latest
# if: ${{ needs.set-version-number.outputs.is-release == 'true' }}
# strategy:
# matrix:
# arch: [ "win-x64", "win-arm64" ]

# steps:
# - uses: actions/checkout@v3
# - uses: actions/download-artifact@v3
# with:
# name: smink-${{ matrix.arch }}-self-contained-${{ needs.set-version-number.outputs.nuGetVersion }}
# path: ${{ matrix.arch }}/

# - name: Create msi
# if: ${{ needs.set-version-number.outputs.is-release == 'true' }}
# run: ./installers/msi/Create-Installer.ps1 -grateExe ./${{ matrix.arch }}/grate.exe -Version "${{ needs.set-version-number.outputs.nuGetVersion }}"
# env:
# VERSION: ${{ needs.set-version-number.outputs.nuGetVersion }}

# - name: Upload MSI ${{ matrix.arch }}
# uses: actions/upload-artifact@v3
# with:
# name: grate-msi-${{ matrix.arch }}-${{ needs.set-version-number.outputs.nuGetVersion }}
# path: ./installers/msi/tmp/*.msi

# build-docker-image:
# name: Build and push docker image
# needs:
# - set-version-number
# - build-standalone
# runs-on: ubuntu-latest
# if: ${{ needs.set-version-number.outputs.is-release == 'true' }}
# env:
# #REGISTRY: ghcr.io
# IMAGE_NAME: ${{ github.repository }}
# FULL_IMAGE_NAME: ${{ github.repository }}

# steps:
# - uses: actions/checkout@v3
# - uses: actions/download-artifact@v3
# with:
# name: grate-alpine-x64-self-contained-${{ needs.set-version-number.outputs.nuGetVersion }}
# path: installers/docker/


# - name: Log in to the Container registry
# uses: docker/login-action@465a07811f14bebb1938fbed4728c6a1ff8901fc
# with:
# #registry: ${{ env.REGISTRY }}
# username: ${{ github.repository_owner}}
# password: ${{ secrets.DOCKER_HUB_TOKEN }}

# - name: Extract metadata (tags, labels) for Docker
# id: meta
# uses: docker/metadata-action@818d4b7b91585d195f67373fd9cb0332e31a7175
# with:
# tags: |
# type=semver,pattern={{version}}
# type=semver,pattern={{version}},value=${{ needs.set-version-number.outputs.semVer }}
# type=ref,event=tag

# #images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
# images: ${{ env.IMAGE_NAME }}


# - name: Build and push Docker image
# uses: docker/build-push-action@2eb1c1961a95fc15694676618e422e8ba1d63825
# with:
# context: ./installers/docker/
# push: true
# tags: ${{ steps.meta.outputs.tags }}
# labels: ${{ steps.meta.outputs.labels }}

# build-deb:
# name: Build Debian package
# needs:
# - set-version-number
# - build-standalone
# runs-on: ubuntu-latest
# if: ${{ needs.set-version-number.outputs.is-release == 'true' }}
# strategy:
# matrix:
# arch: [ "linux-arm", "linux-arm64", "linux-x64" ]

# steps:
# - uses: actions/checkout@v3
# - uses: actions/download-artifact@v3
# with:
# name: smink-${{ matrix.arch }}-self-contained-${{ needs.set-version-number.outputs.nuGetVersion }}
# path: ${{ matrix.arch }}/

# - id: get-arch
# name: Get architecture
# run: |
# arch=$(echo ${{ matrix.arch }} | cut -d- -f2 | sed 's/x64/amd64/')
# echo "::set-output name=arch::$arch"

# - name: Create dpkg
# if: ${{ needs.set-version-number.outputs.is-release == 'true' }}
# run: ./installers/deb/Create-Package.ps1 -grateExe ./${{ matrix.arch }}/grate -Version "${{ needs.set-version-number.outputs.nuGetVersion }}" -arch ${{ steps.get-arch.outputs.arch}}
# env:
# VERSION: ${{ needs.set-version-number.outputs.nuGetVersion }}

# - name: Upload .dpkg ${{ steps.get-arch.outputs.arch }}
# uses: actions/upload-artifact@v3
# with:
# name: grate_${{ needs.set-version-number.outputs.nuGetVersion }}-1_${{ steps.get-arch.outputs.arch}}.deb
# path: ./installers/deb/grate_${{ needs.set-version-number.outputs.nuGetVersion }}-1_${{ steps.get-arch.outputs.arch }}.deb

# build-winget:
# name: Winget - Update package manifest in the OWC
# needs:
# - set-version-number
# - build-msi
# runs-on: windows-latest
# if: ${{ needs.set-version-number.outputs.is-release == 'true' }}

# steps:
# - name: Winget-Create
# run: |

# $version = "$($env:version)"

# # Download wingetcreate
# iwr https://aka.ms/wingetcreate/latest -OutFile wingetcreate.exe

# $packageUrl="https://github.com/erikbra/grate/releases/download/$version/grate-$version.msi"

# echo "Running ./wingetcreate.exe update erikbra.grate -u $packageUrl -v $version -t `"$env:WINGET_GH_PAT`" --submit"
# ./wingetcreate.exe update erikbra.grate -u $packageUrl -v $version -t "$env:WINGET_GH_PAT" --submit
# env:
# WINGET_GH_PAT: ${{ secrets.WINGET_GH_PAT }}
# #version: "1.4.0"
# version: "${{ needs.set-version-number.outputs.nuGetVersion }}"


# test:
# name: Run tests

# runs-on: ubuntu-latest
# strategy:
# matrix:
# category: [ "Basic", "SqlServer", "PostgreSQL", "MariaDB", "Sqlite", "Oracle" ]

# steps:
# - uses: actions/checkout@v3
# - name: Setup .NET 8
# uses: actions/setup-dotnet@v3
# with:
# dotnet-version: 8.0.x
# - name: Test
# run: dotnet test --filter "FullyQualifiedName~grate.unittests.${{ matrix.category }}" -c Release --logger:"trx;LogFilePath=test-results-${{ matrix.category }}.xml" -- -MaxCpuCount 2
# # run: dotnet test --verbosity Normal -c Release --logger "trx;LogFileName=/tmp/test-results/grate.unittests.trx"
# env:
# LogLevel: Warning
# TZ: UTC

Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="XunitXml.TestLogger" Version="3.0.*" />
<PackageReference Include="XunitXml.TestLogger" Version="3.1.*" />
<PackageReference Include="coverlet.collector" Version="3.2.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="XunitXml.TestLogger" Version="3.0.*" />
<PackageReference Include="XunitXml.TestLogger" Version="3.1.*" />
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion smink.UnitTests/smink.UnitTests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="FluentAssertions" Version="6.11.*" />
<PackageReference Include="XunitXml.TestLogger" Version="3.0.*" />
<PackageReference Include="XunitXml.TestLogger" Version="3.1.*" />
</ItemGroup>

<ItemGroup>
Expand Down

0 comments on commit b07e886

Please sign in to comment.