Skip to content

Build Console application #72

Build Console application

Build Console application #72

name: Build Console application
on:
pull_request:
branches: [ "master" ]
types: [opened, synchronize, reopened]
workflow_dispatch:
inputs:
version:
description: 'Version to build (major.minor.patch)'
required: true
default: '0.0.0'
env:
slnFile: 'src/ABulkCopy.sln'
consoleProjFile: 'src/ABulkCopy.Cmd/ABulkCopy.Cmd.csproj'
jobs:
build:
name: Build
runs-on: ubuntu-latest
outputs:
currentVersion: v${{ steps.gitversion.outputs.SemVer }}
steps:
- name: Checkout all
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install GitVersion
if: github.event_name == 'workflow_dispatch'
uses: gittools/actions/gitversion/[email protected]
with:
versionSpec: '5.x'
- name: Build
run: dotnet build ${{env.slnFile}}
- name: Determine version
id: gitversion
if: github.event_name == 'workflow_dispatch'
uses: gittools/actions/gitversion/[email protected]
with:
updateAssemblyInfo: true
useConfigFile: true
overrideConfig: |
next-version=${{ github.event.inputs.version }}
- name: Publish
if: github.event_name == 'workflow_dispatch'
run: dotnet publish ${{env.consoleProjFile}} -c Release
- name: Upload program artifact
if: github.event_name == 'workflow_dispatch'
uses: actions/upload-artifact@v4
with:
name: program
path: ./src/ABulkCopy.Cmd/bin/Release/net8.0/win-x64/publish
- name: Display structure of artifact files
run: ls -R
- name: Upload tests artifact
uses: actions/upload-artifact@v4
with:
name: tests
path: ./src/**/*.Tests
test:
name: Test
runs-on: ubuntu-latest
needs: build
outputs:
currentVersion: ${{ needs.build.outputs.currentVersion }}
steps:
- name: Download artifact
uses: actions/download-artifact@v4
with:
name: tests
- name: Display structure of artifact files
run: ls -R
- name: UnitTest AParser
if: always()
run: dotnet test ./AParser.Tests/bin/Debug/net8.0/AParser.Tests.dll -v m
- name: UnitTest Common
if: always()
run: dotnet test ./Common.Tests/bin/Debug/net8.0/Common.Tests.dll -v m
- name: UnitTest ASqlServer
if: always()
run: dotnet test ./ASqlServer.Tests/bin/Debug/net8.0/ASqlServer.Tests.dll -v m
- name: UnitTest APostgres
if: always()
run: dotnet test ./APostgres.Tests/bin/Debug/net8.0/APostgres.Tests.dll -v m
- name: DbTest SqlServer
if: always()
run: dotnet test ./SqlServer.Tests/bin/Debug/net8.0/SqlServer.Tests.dll -v m
- name: DbTest Postgres
if: always()
run: dotnet test ./Postgres.Tests/bin/Debug/net8.0/Postgres.Tests.dll -v m
- name: DbTests CrossRDBMS
if: always()
run: dotnet test ./CrossRDBMS.Tests/bin/Debug/net8.0/CrossRDBMS.Tests.dll -v m
release:
if: github.event_name == 'workflow_dispatch'
name: Release
runs-on: ubuntu-latest
needs: test
env:
currentVersion: ${{ needs.test.outputs.currentVersion }}
steps:
- name: Download program artifact
uses: actions/download-artifact@v4
with:
name: program
- name: Display structure of artifact files
run: ls -R
- name: Zip release files
uses: thedoctor0/[email protected]
with:
type: 'zip'
filename: 'release.zip'
- name: Create release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ env.currentVersion }}
release_name: Release ${{ env.currentVersion }}
body: |
You can find the release notes [here.](https://arveh.github.io/ABulkCopy.Docs/release_notes/)
draft: false
prerelease: true
- name: List files after zip and creating release
run: ls -R
- name: Upload Release Asset
id: upload-release-asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }} # See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
asset_path: ./release.zip
asset_name: release-${{ env.currentVersion }}.zip
asset_content_type: application/zip