Skip to content

Commit

Permalink
feat: update pipelines to add versionize
Browse files Browse the repository at this point in the history
  • Loading branch information
andrea-dematte-zupit committed Feb 14, 2024
1 parent 517f04b commit 0ec3a20
Show file tree
Hide file tree
Showing 7 changed files with 142 additions and 27 deletions.
48 changes: 48 additions & 0 deletions .github/workflows/publish-new-version-common.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Bump Version common workflow

on:
workflow_call:
inputs:
WORKING_DIRECTORY:
required: true
type: string
PROJECT_NAME_COMMIT_SUFFIX:
required: true
type: string
outputs:
OUTCOME:
description: "Outcome of the versionize action, 'success' if a new version was published"
value: ${{ jobs.publish-new-version.outputs.OUTCOME }}

jobs:
publish-new-version:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ${{ inputs.WORKING_DIRECTORY }}
outputs:
OUTCOME: ${{ steps.versionize.outcome }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: '0'
- name: Install Versionize
run: dotnet tool install --global Versionize
- name: Setup git
run: |
git config --local user.email "zupitdevs@users.noreply.github.com"
git config --local user.name "ZupitDevs"
- name: Versionize Release
id: versionize
run: versionize --changelog-all --exit-insignificant-commits --proj-version-bump-logic --skip-tag --commit-suffix "[${{ inputs.PROJECT_NAME_COMMIT_SUFFIX }}]"
continue-on-error: true
- name: No release required
if: steps.versionize.outcome != 'success'
run: echo "Skipping publishing. No release required."
- name: Push changes to GitHub
if: steps.versionize.outcome == 'success'
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: ${{ github.ref }}
tags: true
43 changes: 23 additions & 20 deletions .github/workflows/release-common.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Release common workflow
name: Release workflow

on:
workflow_call:
Expand All @@ -12,25 +12,28 @@ on:
DOTNET_IMAGE:
required: true
type: string
PROJECT_NAME_COMMIT_SUFFIX:
required: true
type: string

jobs:
test:
uses: ./.github/workflows/test-common.yml
with:
DOTNET_IMAGE: ${{ inputs.DOTNET_IMAGE }}
WORKING_DIRECTORY: ${{ inputs.WORKING_DIRECTORY }}
publish-new-version:
needs: [ test ]
uses: ./.github/workflows/publish-new-version-common.yml
with:
WORKING_DIRECTORY: ${{ inputs.WORKING_DIRECTORY }}
PROJECT_NAME_COMMIT_SUFFIX: ${{ inputs.PROJECT_NAME_COMMIT_SUFFIX }}
release:
runs-on: ubuntu-latest
container:
image: ${{ inputs.DOTNET_IMAGE }}
defaults:
run:
working-directory: ${{ inputs.WORKING_DIRECTORY }}

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Run tests
run: dotnet test

- name: Create NuGet package
run: dotnet pack -c Release -o ./artifacts/${{ inputs.PROJECT }} ${{ inputs.PROJECT }}

- name: Publish NuGet package
run: dotnet nuget push ./artifacts/${{ inputs.PROJECT }}/*.nupkg -s https://api.nuget.org/v3/index.json -k ${{ secrets.ZUPIT_NUGET_TOKEN }}
needs: [ test, publish-new-version ]
if: needs.publish-new-version.outputs.OUTCOME == 'success'
uses: ./.github/workflows/release-nuget-common.yml
with:
DOTNET_IMAGE: ${{ inputs.DOTNET_IMAGE }}
WORKING_DIRECTORY: ${{ inputs.WORKING_DIRECTORY }}
PROJECT: ${{ inputs.PROJECT }}
secrets: inherit
36 changes: 36 additions & 0 deletions .github/workflows/release-nuget-common.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Release to nuget

on:
workflow_call:
inputs:
WORKING_DIRECTORY:
required: true
type: string
PROJECT:
required: true
type: string
DOTNET_IMAGE:
required: true
type: string

jobs:
release:
runs-on: ubuntu-latest
container:
image: ${{ inputs.DOTNET_IMAGE }}
defaults:
run:
working-directory: ${{ inputs.WORKING_DIRECTORY }}

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Create NuGet package
run: dotnet pack -c Release -o ./artifacts/${{ inputs.PROJECT }} ${{ inputs.PROJECT }}

# - name: Publish NuGet package
# run: dotnet nuget push ./artifacts/${{ inputs.PROJECT }}/*.nupkg -s https://api.nuget.org/v3/index.json -k ${{ secrets.ZUPIT_NUGET_TOKEN }}

- name: Publish NuGet package test
run: echo "Publish to Nuget"
3 changes: 2 additions & 1 deletion .github/workflows/release-version-endpoint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@ on:
workflow_dispatch:

jobs:
release-version-endpoint:
release-common:
uses: ./.github/workflows/release-common.yml
with:
DOTNET_IMAGE: 'mcr.microsoft.com/dotnet/sdk:8.0.101-alpine3.18-amd64'
WORKING_DIRECTORY: Zupit.VersionEndpoint
PROJECT: Zupit.VersionEndpoint
PROJECT_NAME_COMMIT_SUFFIX: VersionEndpoint
secrets: inherit
27 changes: 27 additions & 0 deletions .github/workflows/test-common.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Test common workflow

on:
workflow_call:
inputs:
WORKING_DIRECTORY:
required: true
type: string
DOTNET_IMAGE:
required: true
type: string

jobs:
test:
runs-on: ubuntu-latest
container:
image: ${{ inputs.DOTNET_IMAGE }}
defaults:
run:
working-directory: ${{ inputs.WORKING_DIRECTORY }}

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Run tests
run: dotnet test
2 changes: 1 addition & 1 deletion Zupit.VersionEndpoint/Zupit.VersionEndpoint/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ This library adds a version endpoint to your ASP.NET Core application. The versi
The endpoint is accessible via `GET /version` and returns a string with the version. You can customize the endpoint path.

## Prerequisites
- .NET 7 or later
- .NET 7 or later

## Installation
```
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net7.0;net8.0</TargetFrameworks>
Expand All @@ -8,7 +8,7 @@

<PropertyGroup>
<PackageId>Zupit.VersionEndpoint</PackageId>
<Version>0.0.2-alpha</Version>
<Version>0.0.2</Version>
<Authors>Zupit Developers</Authors>
<Company>Zupit</Company>
<PackageTags>Version;Endpoint;Zupit</PackageTags>
Expand All @@ -21,11 +21,11 @@
</PropertyGroup>

<ItemGroup>
<None Include="README.md" Pack="true" PackagePath="\"/>
<None Include="../../icon.png" Pack="true" PackagePath="\"/>
<None Include="README.md" Pack="true" PackagePath="\" />
<None Include="../../icon.png" Pack="true" PackagePath="\" />
</ItemGroup>

<ItemGroup>
<FrameworkReference Include="Microsoft.AspNetCore.App"/>
<FrameworkReference Include="Microsoft.AspNetCore.App" />
</ItemGroup>
</Project>

0 comments on commit 0ec3a20

Please sign in to comment.