Skip to content

Additional pipe methods (#71) #141

Additional pipe methods (#71)

Additional pipe methods (#71) #141

Workflow file for this run

name: CICD
on:
workflow_dispatch:
inputs:
version:
description: 'Version number'
required: true
pull_request:
push:
branches:
- "main"
env:
CI: true
jobs:
version:
name: Create a version number
runs-on: ubuntu-latest
timeout-minutes: 2
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' }}
build:
name: Build package
runs-on: ubuntu-latest
container:
image: mcr.microsoft.com/dotnet/sdk:8.0-jammy
timeout-minutes: 10
needs: [version]
steps:
- uses: actions/checkout@v3
- name: Restore local .NET tools
run: dotnet tool restore
- name: Run tests
run: dotnet test tests/tests.ghulproj
- name: Create package
run: dotnet pack -p:Version=${{ needs.version.outputs.package }}
- name: Upload package artefact
uses: actions/upload-artifact@v4
with:
name: package
path: nupkg
integration-tests:
name: Test package
runs-on: ubuntu-latest
container:
image: mcr.microsoft.com/dotnet/sdk:8.0-jammy
timeout-minutes: 10
needs: [version,build]
steps:
- uses: actions/checkout@v3
- name: Download package
uses: actions/download-artifact@v4
with:
name: package
path: nupkg
- name: Restore local .NET tools
run: dotnet tool restore
- name: Set version
run: dotnet setversion ${{ needs.version.outputs.package }} Directory.Build.props
- name: Build test project
run: dotnet build
working-directory: integration-tests
- name: Run test project
id: run
run: |
STDOUT=$(dotnet run | tr -d '\n\r')
echo "::set-output name=stdout::${STDOUT}"
working-directory: integration-tests
- name: Show test output
run: echo "\"${{ steps.run.outputs.stdout }}\""
- name: Check test output
run: |
if [ "${{ steps.run.outputs.stdout }}" != "Hello ghūl world!" ] ; then
exit 1
fi
working-directory: integration-tests
publish-beta-package:
# for pull requests, only publish the beta package
name: Publish beta NuGet package
runs-on: ubuntu-latest
if: ${{ github.event_name == 'pull_request' && github.actor != 'dependabot[bot]' }}
container:
image: mcr.microsoft.com/dotnet/sdk:8.0-jammy
timeout-minutes: 10
needs: [version,build,integration-tests]
steps:
# not convinced we actually need to checkout the code here
- uses: actions/checkout@v3
- name: Download package
uses: actions/download-artifact@v4
with:
name: package
path: nupkg
- name: Publish package to GitHub
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 }}
publish-release-package:
# For pushes, publish the release package to both GitHub and NuGet
# Don't need to check the branch here, as push only happens on main
name: Publish NuGet package
runs-on: ubuntu-latest
if: ${{ github.event_name == 'push' }}
container:
image: mcr.microsoft.com/dotnet/sdk:8.0-jammy
timeout-minutes: 10
needs: [version,build,integration-tests]
steps:
- uses: actions/checkout@v3
- name: Download 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' || github.event_name == 'workflow_dispatch' }}
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, build, integration-tests, publish-release-package]
name: Create release
runs-on: ubuntu-latest
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.runtime.${{ needs.version.outputs.package }}.nupkg
asset_name: ghul.runtime.${{ needs.version.outputs.package }}.nupkg
asset_content_type: application/octet-stream