Update compiler tool and runtime library (#24) #63
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# CI/CD pipeline. | |
name: CICD | |
on: | |
workflow_dispatch: | |
inputs: | |
version: | |
description: 'Version number' | |
required: true | |
pull_request: | |
push: | |
branches: [master, main] | |
env: | |
CI: true | |
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1 | |
DOTNET_CLI_TELEMETRY_OPTOUT: 1 | |
DOTNET_NOLOGO: 1 | |
jobs: | |
version: | |
name: Create a version number | |
runs-on: ubuntu-latest | |
timeout-minutes: 1 | |
outputs: | |
tag: ${{ steps.create_version.outputs.tag }} | |
package: ${{ steps.create_version.outputs.package }} | |
permissions: | |
contents: 'write' | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: '0' | |
- name: Create version | |
id: create_version | |
uses: degory/create-version@v0.0.2 | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
env: | |
PRERELEASE: ${{ github.event_name == 'pull_request' }} | |
test-console-application: | |
name: Test the console application in-situ | |
runs-on: ubuntu-latest | |
container: | |
image: mcr.microsoft.com/dotnet/sdk:8.0 | |
timeout-minutes: 10 | |
needs: [version] | |
steps: | |
- uses: actions/checkout@v3 | |
- name: .NET tool restore | |
working-directory: templates/ghul-console | |
run: dotnet tool restore | |
- name: Build | |
working-directory: templates/ghul-console | |
run: dotnet build | |
- name: Run | |
id: run | |
working-directory: templates/ghul-console | |
run: | | |
STDOUT=$(dotnet run) | |
echo "::set-output name=stdout::${STDOUT}" | |
- name: Test | |
run: | | |
if [ "${STDOUT}" != "Hello world!" ] ; then | |
exit 1 | |
fi | |
env: | |
STDOUT: ${{ steps.run.outputs.stdout }} | |
build: | |
name: Build the package | |
runs-on: ubuntu-latest | |
container: | |
image: mcr.microsoft.com/dotnet/sdk:8.0 | |
timeout-minutes: 10 | |
needs: [version] | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Create package | |
run: dotnet pack -p:Version=${{ needs.version.outputs.package }} | |
- name: Upload .NET package artefact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: package | |
path: nupkg | |
test-console-template: | |
name: Test the console template | |
runs-on: ubuntu-latest | |
container: | |
image: mcr.microsoft.com/dotnet/sdk:8.0 | |
timeout-minutes: 10 | |
needs: [version,build] | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Download template package | |
uses: actions/download-artifact@v4 | |
with: | |
name: package | |
path: nupkg | |
- name: Install templates from the package | |
run: dotnet new -i nupkg/ghul.templates.${{ needs.version.outputs.package }}.nupkg | |
- name: Create project folder | |
run: mkdir project | |
- name: Instantiate the console template | |
run: dotnet new ghul-console | |
working-directory: project | |
- name: Local .NET tools restore | |
run: dotnet tool restore | |
working-directory: project | |
- name: Build | |
run: dotnet build | |
working-directory: project | |
- name: Run | |
id: run | |
run: | | |
STDOUT=$(dotnet run) | |
echo "::set-output name=stdout::${STDOUT}" | |
working-directory: project | |
- name: Test | |
run: | | |
if [ "${STDOUT}" != "Hello world!" ] ; then | |
exit 1 | |
fi | |
working-directory: project | |
env: | |
STDOUT: ${{ steps.run.outputs.stdout }} | |
test-classlib-template: | |
name: Test the classlib template | |
runs-on: ubuntu-latest | |
container: | |
image: mcr.microsoft.com/dotnet/sdk:8.0 | |
timeout-minutes: 10 | |
needs: [version,build] | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Download template package | |
uses: actions/download-artifact@v4 | |
with: | |
name: package | |
path: nupkg | |
- name: Install templates from the package | |
run: dotnet new -i nupkg/ghul.templates.${{ needs.version.outputs.package }}.nupkg | |
- name: Create project folder | |
run: mkdir project | |
- name: Instantiate the classlib template | |
run: dotnet new ghul-classlib | |
working-directory: project | |
- name: Local .NET tools restore (template project) | |
run: dotnet tool restore | |
working-directory: project | |
- name: Create temporary package folder | |
run: mkdir -p tests/packages | |
- name: Pack | |
run: dotnet pack -o ../tests/packages | |
working-directory: project | |
- name: Local .NET tools restore (test project) | |
run: dotnet tool restore | |
working-directory: tests/ghul-classlib | |
- name: Test | |
run: dotnet test | |
working-directory: tests/ghul-classlib | |
publish-package: | |
name: Publish the package | |
runs-on: ubuntu-latest | |
container: | |
image: mcr.microsoft.com/dotnet/sdk:8.0 | |
timeout-minutes: 10 | |
needs: [test-console-template,test-classlib-template] | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Download template package | |
uses: actions/download-artifact@v4 | |
with: | |
name: package | |
path: nupkg | |
- name: Publish package to GitHub | |
if: ${{ github.actor != 'dependabot[bot]' }} | |
run: dotnet nuget push ./nupkg/*.nupkg -k ${GITHUB_TOKEN} -s https://nuget.pkg.github.com/degory/index.json --skip-duplicate --no-symbols | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Publish package to NuGet | |
if: ${{ github.event_name == 'push' }} | |
run: dotnet nuget push ./nupkg/*.nupkg -k ${NUGET_TOKEN} -s https://api.nuget.org/v3/index.json --skip-duplicate --no-symbols | |
env: | |
NUGET_TOKEN: ${{ secrets.NUGET_TOKEN }} | |
create_release: | |
needs: [version, publish-package] | |
name: Create release | |
runs-on: ubuntu-20.04 | |
timeout-minutes: 5 | |
if: ${{ github.event_name == 'push' }} | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Download package | |
uses: actions/download-artifact@v4 | |
with: | |
name: package | |
path: nupkg | |
- name: Create changelog | |
run: git log -1 --format="%s%n%n%b%n%n" >changelog.txt | |
- name: Create a Release | |
id: create_release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: ${{ needs.version.outputs.tag }} | |
release_name: ${{ needs.version.outputs.tag }} | |
body_path: changelog.txt | |
draft: false | |
- name: Upload package asset | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: ./nupkg/ghul.templates.${{ needs.version.outputs.package }}.nupkg | |
asset_name: ghul.templates.${{ needs.version.outputs.package }}.nupkg | |
asset_content_type: application/octet-stream |