Skip to content

Commit

Permalink
Integrate SemVer with Release pipeline (#4)
Browse files Browse the repository at this point in the history
* ci: do not fail if no new version, warning is sufficient

* chore: use latest language verion in csproj files

* chore: disable AssemblyInfo auto-generation

* Chore: clean up csproj files

* chore: install GitInfo NuGet package

* chore: consum GitInfo for AssemblyInfo file gen

* chore: clean up spaces for file dirs

* chore: remove old version

* Use the GitInfo to display the app version

* ci: build with the release tag

* ci: rovide friendly names on PR steps

* ci: Fix published ZIP folder structure

* ci: Fix the targeted solution file

* ci: fix the build solution file

* ci: Rename the generated ZIP files

* ci: Encountered an MSBuild issue, so mitigate in MSBuild csproj?

* ci: Try forcing the codegen

* ci: let's try spinning

* CI: only gen ThisAssembly on the one project

* CI: try this
devlooped/GitInfo#273

* CI: Remove branch name for cleanliness

* CI: set version and such

* CI: drop this

* try stuff

* CI: downgrade

* CI: fetch tags

* Screw around with GitVersion/GitTools

* Install GitVersion.MsBuild

* Uninstall GitInfo

* Removing GitVersion cruft

* check PR for valid labels and stuff

* move around params

* attempt to update SemVer with main

* changing how the version is retrieved

* CI refused a list

* CI refuses a list

* MergeMessageOnly

* Finally hit my intended versioning scheme

* Update to display regular versionon merge

* add labeles

* add in "edited"

* Give step a name

* cancel in progress

* Revert to main, I'll screw around as needed

-- begin release notes --
Adding SemVer calculation to CI
-- end release notes --
  • Loading branch information
BardezAnAvatar authored May 17, 2024
1 parent bfe035c commit 21b6209
Show file tree
Hide file tree
Showing 14 changed files with 212 additions and 215 deletions.
4 changes: 2 additions & 2 deletions .github/actions/build/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ runs:

- name: Restore Packages
shell: PowerShell
run: nuget restore "SotS Savegame Editor.sln"
run: nuget restore "Bardez.Project.SwordOfTheStars.Editor.sln"

- name: Build Solution
shell: PowerShell
run: |
msbuild.exe "SotS Savegame Editor.sln" `
msbuild.exe "Bardez.Project.SwordOfTheStars.Editor.sln" `
/nologo /nr:false `
/p:DeployOnBuild=true `
/p:DeployDefaultTarget=WebPublish `
Expand Down
2 changes: 1 addition & 1 deletion .github/actions/publish-artifact-pr/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ runs:
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: pr_${{ github.event.number }}_release
name: sots-sge_pr_${{ github.event.number }}
path: ${{ github.workspace }}/_build/
retention-days: 5
72 changes: 36 additions & 36 deletions .github/workflows/ci-main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,42 +6,54 @@ on:
- main

jobs:
semver:
name: Compute SemVer
bump-tag-version:
name: Bump and Tag Version
runs-on: ubuntu-latest
outputs:
semver_current: ${{ steps.semver.outputs.current }}
semver_next: ${{ steps.semver.outputs.next }}

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

#SemVer calculation
- name: Get Next Version
- uses: jefflinse/pr-semver-bump@v1.6.0
name: Bump and Tag Version
id: semver
uses: ietf-tools/semver-action@v1
with:
token: ${{ github.token }}
branch: main
mode: bump
repo-token: ${{ secrets.GITHUB_TOKEN }}
major-label: SemVer Major
minor-label: SemVer Minor
patch-label: SemVer Patch
noop-labels: ''
require-release-notes: true
release-notes-prefix: -- begin release notes --
release-notes-suffix: -- end release notes --
with-v: false
base-branch: false
outputs:
semver_old: ${{ steps.semver.outputs.old-version }}
semver_next: ${{ steps.semver.outputs.version }}
semver_skipped: ${{ steps.semver.outputs.skipped }}
semver_release-notes: ${{ steps.semver.outputs.release-notes }}


build:
name: Build Release
if: ${{ needs.semver.outputs.semver_current != needs.semver.outputs.semver_next }}
if: ${{ needs.bump-tag-version.outputs.semver_skipped != true }}
runs-on: windows-2019
needs: bump-tag-version

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

#SemVer calculation
- name: Get Next Version
id: semver
uses: ietf-tools/semver-action@v1
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
with:
token: ${{ github.token }}
branch: main
tag_name: ${{ needs.semver.outputs.semver_next }}
release_name: Release ${{ needs.semver.outputs.semver_next }}
body: ${{ github.event.head_commit.message }}
draft: false
prerelease: false

- uses: ./.github/actions/build/
name: Build Release
Expand All @@ -52,31 +64,19 @@ jobs:
- name: Compress Build
run: |
$compress = @{
Path = "${{ github.workspace }}/_build/"
Path = "${{ github.workspace }}/_build/*"
CompressionLevel = "Fastest"
DestinationPath = "${{ github.workspace }}/_release/release_${{ steps.semver.outputs.next }}.zip"
DestinationPath = "${{ github.workspace }}/_release/sots-sge_{{ needs.semver.outputs.semver_next }}.zip"
}
Compress-Archive @compress
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
with:
tag_name: ${{ steps.semver.outputs.next }}
release_name: Release ${{ steps.semver.outputs.next }}
body: ${{ github.event.head_commit.message }}
draft: false
prerelease: false

- 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 }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `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: ${{ github.workspace }}/_release/release_${{ steps.semver.outputs.next }}.zip
asset_name: release_${{ steps.semver.outputs.next }}.zip
asset_path: ${{ github.workspace }}/_release/release_${{ needs.semver.outputs.semver_next }}.zip
asset_name: release_${{ needs.semver.outputs.semver_next }}.zip
asset_content_type: application/zip
35 changes: 35 additions & 0 deletions .github/workflows/ci-pull-request.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,53 @@ name: "Continous Integration: PRs"
on:
pull_request:
types:
- labeled
- unlabeled
- edited
- opened
- reopened
- ready_for_review
- review_requested
- synchronize
# - edited #updating PR title, body, state or base?

concurrency:
group: ${{ github.head_ref }}
cancel-in-progress: true

jobs:
check-pr:
name: Validate Release Label and Notes
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
name: Checkouts
- uses: jefflinse/pr-semver-bump@v1.6.0
name: Validate Pull Request Metadata
with:
mode: validate
repo-token: ${{ secrets.GITHUB_TOKEN }}
major-label: SemVer Major
minor-label: SemVer Minor
patch-label: SemVer Patch
noop-labels: ''
require-release-notes: true
release-notes-prefix: -- begin release notes --
release-notes-suffix: -- end release notes --

build:
name: Build Solution
runs-on: windows-2019
needs: check-pr

steps:
- uses: actions/checkout@v4
name: Checkout Source
with:
fetch-tags: true

- uses: ./.github/actions/build/
name: Build Source

- uses: ./.github/actions/publish-artifact-pr/
name: Publish Artifact
27 changes: 8 additions & 19 deletions Bardez.Project.Configuration/Bardez.Project.Configuration.csproj
Original file line number Diff line number Diff line change
@@ -1,24 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<ProductVersion>8.0.50727</ProductVersion>
<RootNamespace>Bardez.Project.Configuration</RootNamespace>
<AssemblyName>Bardez.Project.Configuration</AssemblyName>
<LangVersion>latest</LangVersion>
<TargetFramework>net48</TargetFramework>
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
<UpdateEnabled>false</UpdateEnabled>
<UpdateMode>Foreground</UpdateMode>
<UpdateInterval>7</UpdateInterval>
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
<UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<IsWebBootstrapper>false</IsWebBootstrapper>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
<AssemblyTitle>Configuration Handler</AssemblyTitle>
<Copyright>Copyright © Bardez 2024</Copyright>
<Product>Configuration Handler</Product>
Expand All @@ -32,8 +15,14 @@
<DebugType>pdbonly</DebugType>
<UseVSHostingProcess>true</UseVSHostingProcess>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="GitVersion.MsBuild" Version="5.12.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>
<ItemGroup>
<Reference Include="System.Configuration" />
<Reference Include="System.Web" />
</ItemGroup>
</Project>
</Project>
11 changes: 0 additions & 11 deletions Bardez.Project.Configuration/Properties/AssemblyInfo.cs

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<ProductVersion>8.0.30703</ProductVersion>
<LangVersion>latest</LangVersion>
<RootNamespace>Bardez.Project.ExceptionHandler</RootNamespace>
<TargetFramework>net48</TargetFramework>
<AssemblyTitle>Exception Handler</AssemblyTitle>
Expand All @@ -14,6 +14,12 @@
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="GitVersion.MsBuild" Version="5.12.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>
<ItemGroup>
<Reference Include="System.Management" />
<Reference Include="System.Windows.Forms" />
Expand All @@ -24,4 +30,4 @@
<ItemGroup>
<ProjectReference Include="..\Bardez.Project.Configuration\Bardez.Project.Configuration.csproj" />
</ItemGroup>
</Project>
</Project>
11 changes: 0 additions & 11 deletions Bardez.Project.ExceptionHandler/Properties/AssemblyInfo.cs

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<ProductVersion>8.0.30703</ProductVersion>
<RootNamespace>Bardez.Project.SwordOfTheStars.DataStructures</RootNamespace>
<LangVersion>latest</LangVersion>
<TargetFramework>net48</TargetFramework>
<Copyright>Copyright © Bardez 2024</Copyright>
<OutputPath>bin\$(Configuration)\</OutputPath>
Expand All @@ -13,9 +12,10 @@
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
</PropertyGroup>
<PropertyGroup>
<StartupObject />
</PropertyGroup>
<ItemGroup>
<PackageReference Include="GitVersion.MsBuild" Version="5.12.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>
</Project>
</Project>
Loading

0 comments on commit 21b6209

Please sign in to comment.