diff --git a/.github/workflows/Pre-version.yml b/.github/workflows/Pre-version.yml new file mode 100644 index 0000000..ed591f4 --- /dev/null +++ b/.github/workflows/Pre-version.yml @@ -0,0 +1,10 @@ +name: 'Build Pre-release' +on: + workflow_dispatch: + +jobs: + build: + uses: ./.github/workflows/sw_build.yml + with: + gitversion-config: './.github/GitVersion.yml' + push_artifact: true diff --git a/.github/workflows/Pull-Request-Labeler.yml b/.github/workflows/Pull-Request-Labeler.yml index bf03334..c4aa3ba 100644 --- a/.github/workflows/Pull-Request-Labeler.yml +++ b/.github/workflows/Pull-Request-Labeler.yml @@ -7,6 +7,7 @@ jobs: pr-labeler: runs-on: ubuntu-latest steps: - - uses: TimonVS/pr-labeler-action@v3 + - uses: TimonVS/pr-labeler-action@v5.0.0 env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + diff --git a/.github/workflows/Pull-Request.yml b/.github/workflows/Pull-Request.yml index fa75d0a..f359279 100644 --- a/.github/workflows/Pull-Request.yml +++ b/.github/workflows/Pull-Request.yml @@ -5,15 +5,8 @@ on: workflow_dispatch: jobs: - init: - uses: elendil-software/github-actions/.github/workflows/init-workflow.yml@main - - gitversion: - needs: init - uses: elendil-software/github-actions/.github/workflows/gitversion.yml@main - with: - config: './.github/GitVersion.yml' - build: - needs: gitversion - uses: elendil-software/github-actions/.github/workflows/dotnet-build.yml@main \ No newline at end of file + uses: ./.github/workflows/sw_build.yml + with: + gitversion-config: './.github/GitVersion.yml' + push_artifact: false \ No newline at end of file diff --git a/.github/workflows/Push-Dev-Nuget.yml b/.github/workflows/Push-Dev-Nuget.yml deleted file mode 100644 index fcdbf4e..0000000 --- a/.github/workflows/Push-Dev-Nuget.yml +++ /dev/null @@ -1,21 +0,0 @@ -name: 'Push Developement NuGet' -on: - workflow_dispatch: - -jobs: - init: - uses: elendil-software/github-actions/.github/workflows/init-workflow.yml@main - - gitversion: - needs: init - uses: elendil-software/github-actions/.github/workflows/gitversion.yml@main - with: - config: './.github/GitVersion.yml' - - build: - needs: gitversion - uses: elendil-software/github-actions/.github/workflows/dotnet-build.yml@main - - nuget-push: - needs: build - uses: elendil-software/github-actions/.github/workflows/nuget-push-github.yml@main \ No newline at end of file diff --git a/.github/workflows/Release.yml b/.github/workflows/Release.yml index ef08a78..578bd17 100644 --- a/.github/workflows/Release.yml +++ b/.github/workflows/Release.yml @@ -3,33 +3,15 @@ on: workflow_dispatch: jobs: - init: - uses: elendil-software/github-actions/.github/workflows/init-workflow.yml@main - - gitversion: - needs: init - uses: elendil-software/github-actions/.github/workflows/gitversion.yml@main - with: - config: './.github/GitVersion-Release.yml' - build: - needs: gitversion - uses: elendil-software/github-actions/.github/workflows/dotnet-build.yml@main - - nuget-push: - needs: build - uses: elendil-software/github-actions/.github/workflows/nuget-push-nugetorg.yml@main - secrets: - NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }} + uses: ./.github/workflows/sw_build.yml + with: + gitversion-config: './.github/GitVersion-Release.yml' + push_artifact: true release: - needs: [gitversion, build] - uses: elendil-software/github-actions/.github/workflows/tag-release.yml@main + needs: [build] + uses: ./.github/workflows/sw_tag-release.yml with: - git_config_user_email: 'git@elendil.software' - git_config_user_name: ${{ github.repository_owner }} - git_tag: ${{needs.gitversion.outputs.SemVer}} - changelog_builder_configuration: './.github/release-changelog-builder-configuration.json' - release_artifacts: "**/*.nupkg" - secrets: - SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }} \ No newline at end of file + git_tag: ${{needs.build.outputs.SemVer}} + changelog_builder_configuration: './.github/release-changelog-builder-configuration.json' \ No newline at end of file diff --git a/.github/workflows/sw_build.yml b/.github/workflows/sw_build.yml new file mode 100644 index 0000000..005fa2b --- /dev/null +++ b/.github/workflows/sw_build.yml @@ -0,0 +1,87 @@ +name: 'Build (Sub-Workflow)' +on: + workflow_call: + inputs: + gitversion-config: + description: 'Path to GitVersion configuration file' + required: true + type: string + push_artifact: + description: 'Push the generated artifact' + default: false + required: false + type: boolean + artifact_name_out: + description: 'Name of the artifact' + default: 'artifact' + required: false + type: string + artifact_retention_days: + description: 'retention days for the artifact' + default: 5 + required: false + type: number + + outputs: + MajorMinorPatch: + value: ${{ jobs.build.outputs.MajorMinorPatch }} + SemVer: + value: ${{ jobs.build.outputs.SemVer }} + +jobs: + build: + name: 'Build' + runs-on: windows-latest + outputs: + MajorMinorPatch: ${{ steps.gitversion.outputs.MajorMinorPatch }} + SemVer: ${{ steps.gitversion.outputs.SemVer }} + + steps: + - name: 'Checkout' + uses: actions/checkout@v4.2.2 + with: + fetch-depth: 0 + + - name: 'Setup MSBuild' + uses: microsoft/setup-msbuild@v2 + + - name: 'Setup GitVersion' + uses: gittools/actions/gitversion/setup@v1.2.0 + with: + versionSpec: '5.x' + + - name: 'GitVersion updateprojectfiles' + id: gitversion + uses: gittools/actions/gitversion/execute@v1.2.0 + with: + useConfigFile: true + configFilePath: ${{ inputs.gitversion-config }} + additionalArguments: '/updateprojectfiles' + + - name: 'Build' + run: dotnet build ./IPX800cs/IPX800cs.csproj --configuration Release --output ./Output/IPX800cs + + - name: 'Run tests' + run: dotnet test ./IPX800cs.sln --configuration Release --collect:"XPlat Code Coverage" + + - name: 'Report Generator' + uses: danielpalme/ReportGenerator-GitHub-Action@5.1.13 + with: + reports: './**/TestResults/**/coverage.cobertura.xml' + targetdir: 'coveragereport' + reporttypes: 'HtmlSummary' + + - name: 'Upload coverage report artifact' + uses: actions/upload-artifact@v4.5.0 + with: + name: CoverageReport + path: coveragereport + retention-days: ${{ inputs.artifact_retention_days }} + + - name: 'Upload source artifact' + if: ${{ inputs.push_artifact == true }} + uses: actions/upload-artifact@v4.5.0 + with: + name: ${{ inputs.artifact_name_out }} + path: ./Output/IPX800cs/*.nupkg + retention-days: ${{ inputs.artifact_retention_days }} diff --git a/.github/workflows/sw_tag-release.yml b/.github/workflows/sw_tag-release.yml new file mode 100644 index 0000000..997d689 --- /dev/null +++ b/.github/workflows/sw_tag-release.yml @@ -0,0 +1,65 @@ +name: 'Tag & Release (Sub-Workflow)' +on: + workflow_call: + inputs: + git_tag: + description: 'Git tag to create' + required: true + type: string + artifact_name_in: + description: 'Name of an artifact saved by a previous workflow' + default: 'artifact' + required: false + type: string + changelog_builder_configuration: + description: 'Relative path to the configuration.json file for the mikepenz/release-changelog-builder-action' + required: true + type: string + +jobs: + release: + name: 'Create Tag and Release' + runs-on: ubuntu-latest + steps: + - name: 'Checkout' + uses: actions/checkout@v4.2.2 + with: + fetch-depth: 0 + + - name: 'Download source artifact' + uses: actions/download-artifact@v4.1.8 + with: + name: ${{ inputs.artifact_name_in }} + path: ${{ inputs.artifact_name_in }} + + - name: 'Create Tag' + id: tag_version + uses: mathieudutour/github-tag-action@v6.2 + with: + tag_prefix: '' + custom_tag: ${{ inputs.git_tag }} + github_token: ${{ secrets.GITHUB_TOKEN }} + + - name: 'Build Changelog' + id: build_changelog + uses: mikepenz/release-changelog-builder-action@v5.0.0 + with: + failOnError: true + configuration: '${{ inputs.changelog_builder_configuration }}' + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: 'Create Release' + uses: ncipollo/release-action@v1.12.0 + with: + artifactErrorsFailBuild: true + draft: false + body: '${{steps.build_changelog.outputs.changelog}}' + tag: '${{ inputs.git_tag }}' + artifacts: '${{ inputs.artifact_name_in }}/*' + token: ${{ secrets.GITHUB_TOKEN }} + + - name: 'Push .nupkg files to nuget.org' + run: dotnet nuget push ${{ inputs.artifact_name_in }}/*.nupkg --api-key $API_KEY --source https://api.nuget.org/v3/index.json + env: + API_KEY: ${{ secrets.NUGET_API_KEY }} \ No newline at end of file diff --git a/IPX800cs.sln b/IPX800cs.sln index b39bfba..b7a2919 100644 --- a/IPX800cs.sln +++ b/IPX800cs.sln @@ -26,9 +26,11 @@ EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "workflows", "workflows", "{0D379098-AE02-4E0F-87CB-97BC89C80A28}" ProjectSection(SolutionItems) = preProject .github\workflows\Release.yml = .github\workflows\Release.yml - .github\workflows\Push-Dev-Nuget.yml = .github\workflows\Push-Dev-Nuget.yml .github\workflows\Pull-Request-Labeler.yml = .github\workflows\Pull-Request-Labeler.yml .github\workflows\Pull-Request.yml = .github\workflows\Pull-Request.yml + .github\workflows\sw_tag-release.yml = .github\workflows\sw_tag-release.yml + .github\workflows\sw_build.yml = .github\workflows\sw_build.yml + .github\workflows\Pre-version.yml = .github\workflows\Pre-version.yml EndProjectSection EndProject Global