Skip to content

Commit

Permalink
Update workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
kzrnm committed Feb 25, 2022
1 parent 61af590 commit 2af328e
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 121 deletions.
117 changes: 21 additions & 96 deletions .github/workflows/build-release-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,127 +11,52 @@ env:
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
DOTNET_NOLOGO: true
NUGET_XMLDOC_MODE: skip
NUGET_PACKAGES: ${{ github.workspace }}/.nuget/packages
WORKFLOW_VERSION_PROJ: Base32768/Base32768.csproj
WORKFLOW_BUILD_SLN: Base32768.sln

jobs:
get-version:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.get-version.outputs.version }}
is-new: ${{ steps.is-new-version.outputs.is-new }}
is-prerelease: ${{ steps.is-new-version.outputs.is-prerelease }}
steps:
- uses: actions/checkout@v2
- name: Get version
uses: naminodarie/get-net-sdk-project-versions-action@v1
id: get-version
with:
proj-path: ${{ env.WORKFLOW_VERSION_PROJ }}
- name: Check tag
uses: mukunku/tag-exists-action@v1.0.0
id: check-tag
with:
tag: v${{ steps.get-version.outputs.version }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: is new version?
id: is-new-version
run: |
IS_PRE=false
IS_NEW=false
if [ "${{ steps.get-version.outputs.version }}" = "${GITHUB_REF#refs/tags/v}" ]; then
echo "create version tag event: $GITHUB_REF"
if [ "${{ steps.get-version.outputs.version-suffix }}" != "" ]; then
IS_PRE=true
fi
IS_NEW=true
elif [ "${{ steps.check-tag.outputs.exists }}" = "false" ]; then
echo "new version tag project: ${{ steps.get-version.outputs.version }}"
if [ "${{ steps.get-version.outputs.version-suffix }}" != "" ]; then
IS_PRE=true
fi
IS_NEW=true
fi
echo "::set-output name=is-new::$IS_NEW"
echo "::set-output name=is-prerelease::$IS_PRE"
uses: kzrnm/dotnet-actions/.github/workflows/get-version.yml@v1
with:
project-path: Base32768/Base32768.csproj

format:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Setup .NET 6 SDK
uses: actions/setup-dotnet@v1
with:
dotnet-version: 6.0.x
- name: Format
run: dotnet format ${{ env.WORKFLOW_BUILD_SLN }} --verify-no-changes
uses: kzrnm/dotnet-actions/.github/workflows/format.yml@v1
with:
target: Base32768.sln
dotnet-version: 6.0.x

build:
runs-on: windows-latest
needs: [get-version]
steps:
- uses: actions/checkout@v2
- name: Setup .NET 6 SDK
- name: Setup .NET SDK
uses: actions/setup-dotnet@v1
with:
dotnet-version: 6.0.x
- uses: actions/cache@v2
with:
path: ${{ github.workspace }}/.nuget/packages
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }}
restore-keys: |
${{ runner.os }}-nuget-
- name: Build & Test
run: dotnet test ${{ env.WORKFLOW_BUILD_SLN }} --logger GitHubActions -c Release
- name: Build
run: dotnet build ${{ env.WORKFLOW_BUILD_SLN }} -c Release
- name: Test
run: dotnet test ${{ env.WORKFLOW_BUILD_SLN }} --no-build --logger GitHubActions -c Release
- uses: actions/upload-artifact@v1
if: ${{ needs.get-version.outputs.is-new == 'true' }}
with:
name: dist
path: bin/Packages/Release

new-version-only:
runs-on: ubuntu-latest
publish:
needs: [get-version, build, format]
if: ${{ needs.get-version.outputs.is-new == 'true' }}
steps:
- run: echo "new-version"

release:
runs-on: ubuntu-latest
needs: [get-version, new-version-only]
steps:
- name: Download artifact
uses: actions/download-artifact@v2
with:
name: dist
path: dist
- name: Push tag
id: tag-version
uses: mathieudutour/github-tag-action@v5
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
custom_tag: ${{ needs.get-version.outputs.version }}
tag_prefix: "v"
- name: Create release
uses: ncipollo/release-action@v1
id: create-release
with:
token: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ steps.tag-version.outputs.new_tag }}
name: Version ${{ needs.get-version.outputs.version }}
body: https://github.com/${{ github.repository }}/blob/${{ steps.tag-version.outputs.new_tag }}/CHANGELOG.md
artifacts: "./dist/*.nupkg,./dist/*.snupkg"
prerelease: ${{ needs.get-version.outputs.is-prerelease }}
publish:
runs-on: ubuntu-latest
needs: [new-version-only]
steps:
- name: Download artifact
uses: actions/download-artifact@v2
with:
name: dist
path: dist
- name: Upload nuget
run: dotnet nuget push "./dist/*.nupkg" --skip-duplicate --source https://api.nuget.org/v3/index.json --api-key ${{ secrets.NUGET_KEY }}
uses: kzrnm/dotnet-actions/.github/workflows/publish.yml@v1
with:
artifact-name: dist
version: ${{ needs.get-version.outputs.version }}
is-prerelease: ${{ needs.get-version.outputs.is-prerelease }}
secrets:
NUGET_KEY: ${{ secrets.NUGET_KEY }}
34 changes: 9 additions & 25 deletions .github/workflows/unittest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,33 +10,17 @@ env:
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
DOTNET_NOLOGO: true
NUGET_XMLDOC_MODE: skip
NUGET_PACKAGES: ${{ github.workspace }}/.nuget/packages
WORKFLOW_BUILD_SLN: Base32768.sln

jobs:
format:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Setup .NET 6 SDK
uses: actions/setup-dotnet@v1
with:
dotnet-version: 6.0.x
- name: Format
run: dotnet format ${{ env.WORKFLOW_BUILD_SLN }} --verify-no-changes
uses: kzrnm/dotnet-actions/.github/workflows/format.yml@v1
with:
target: Base32768.sln
dotnet-version: 6.0.x
test:
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
- name: Setup .NET 6 SDK
uses: actions/setup-dotnet@v1
with:
dotnet-version: 6.0.x
- uses: actions/cache@v2
with:
path: ${{ github.workspace }}/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }}
restore-keys: |
${{ runner.os }}-nuget-
- name: Build & Test
run: dotnet test ${{ env.WORKFLOW_BUILD_SLN }} --logger GitHubActions
uses: kzrnm/dotnet-actions/.github/workflows/unittest.yml@v1
with:
target: Base32768.sln
dotnet-version: 6.0.x
test-logger: GitHubActions

0 comments on commit 2af328e

Please sign in to comment.