Automatic release #37
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Automatic release | |
on: | |
workflow_dispatch: | |
inputs: | |
min_game_version: | |
type: string | |
description: Minimum game version | |
required: true | |
update_timber_api: | |
type: boolean | |
description: Update TimberAPI | |
default: false | |
required: true | |
timber_api_update_type: | |
type: choice | |
default: beta | |
description: Update type | |
required: false | |
options: | |
- major | |
- feature | |
- bug | |
- alpha | |
- beta | |
- rc | |
make_active_file_in_modio: | |
type: boolean | |
description: Make active file in Mod.io | |
default: false | |
required: true | |
update_timber_api_example: | |
type: boolean | |
description: Update TimberAPIExample | |
required: true | |
timber_api_example_update_type: | |
type: choice | |
default: beta | |
description: Update type | |
required: false | |
options: | |
- major | |
- feature | |
- bug | |
- alpha | |
- beta | |
- rc | |
env: | |
#Timber API | |
timber_api_release_name: "TimberAPI" | |
timber_api_project_path: "Core/TimberApi/TimberApi.csproj" | |
timber_api_output_path: "Core/TimberApi/bin/RELEASE/netstandard2.1" | |
timber_api_nuget_path: "Core/TimberApi/bin/RELEASE" | |
timber_api_common_project_path: "Core/TimberApi.Common/TimberApi.Common.csproj" | |
timber_api_common_output_path: "Core/TimberApi.Common/bin/RELEASE/netstandard2.1" | |
timber_api_common_nuget_path: "Core/TimberApi.Common/bin/RELEASE" | |
timber_api_core_project_path: "Core/TimberApi.Core/TimberApi.Core.csproj" | |
timber_api_core_output_path: "Core/TimberApi.Core/bin/RELEASE/netstandard2.1" | |
timber_api_loaders_project_path: "Loaders/TimberApi.BepInEx.Plugin.Loader" | |
timber_api_loaders_output_path: "Loaders/TimberApi.BepInEx.Plugin.Loader/bin/RELEASE/netstandard2.1" | |
timber_api_assets_folder: "Assets" | |
timber_api_package_folder: "ModIoPackage" | |
timber_api_package_dll_folder: "ModIoPackage/TimberApi/core" | |
timber_api_package_assets_folder: "ModIoPackage/TimberApi/core/assets" | |
#Timber API Example | |
timber_api_example_release_name: "TimberAPI Example" | |
timber_api_example_project_path: "Examples/TimberAPIExample.csproj" | |
timber_api_example_output_path: "Examples/bin/RELEASE/netstandard2.1" | |
timber_api_example_package_dir: "Examples/ThunderstorePackage" | |
jobs: | |
# Automatic updating semantic versioning | |
versions: | |
name: Parse project versions | |
runs-on: ubuntu-latest | |
outputs: | |
timber_api: ${{ github.event.inputs.update_timber_api == 'false' && steps.timber_api.outputs.match || steps.bump_timber_api_version.outputs.next-version }} | |
timber_api_example: ${{ github.event.inputs.update_timber_api_example == 'false' && steps.timber_api_example.outputs.match || steps.bump_timber_api_example_version.outputs.next-version }} | |
timber_api_leading_zero: ${{ github.event.inputs.update_timber_api == 'false' && steps.timber_api.outputs.match || steps.timber_api_version_finalized.outputs.replaced }} | |
timber_api_example_leading_zero: ${{ github.event.inputs.update_timber_api_example == 'false' && steps.timber_api_example.outputs.match || steps.timber_api_example_version_finalized.outputs.replaced }} | |
steps: | |
- uses: actions/checkout@v3 | |
# Loading versioning file | |
- name: Read versions.txt | |
id: read_versions_file | |
uses: juliangruber/read-file-action@v1 | |
with: | |
path: ./project_versions.txt | |
# TimberAPI versioning | |
- id: timber_api | |
uses: actions-ecosystem/action-regex-match@v2 | |
with: | |
text: ${{ steps.read_versions_file.outputs.content }} | |
regex: '(?<=TIMBER_API=).*' | |
- id: bump_timber_api_version | |
uses: christian-draeger/[email protected] | |
with: | |
current-version: ${{ steps.timber_api.outputs.match }} | |
version-fragment: ${{ github.event.inputs.timber_api_update_type }} | |
- name: Concat string | |
id: timber_api_version_finalized | |
uses: greguintow/concat-string-action@v2 | |
with: | |
string: '0.${{ steps.bump_timber_api_version.outputs.next-version }}' | |
# TimberAPI Example versioning | |
- id: timber_api_example | |
uses: actions-ecosystem/action-regex-match@v2 | |
with: | |
text: ${{ steps.read_versions_file.outputs.content }} | |
regex: '(?<=TIMBER_API_EXAMPLE=).*' | |
- id: bump_timber_api_example_version | |
uses: christian-draeger/[email protected] | |
with: | |
current-version: ${{ steps.timber_api_example.outputs.match }} | |
version-fragment: ${{ github.event.inputs.timber_api_example_update_type }} | |
- name: Concat string | |
id: timber_api_example_version_finalized | |
uses: greguintow/concat-string-action@v2 | |
with: | |
string: '0.${{ steps.bump_timber_api_example_version.outputs.next-version }}' | |
publish_timber_api_nuget: | |
if: ${{ github.event.inputs.timber_api_update_type == 'major' || github.event.inputs.timber_api_update_type == 'feature' || github.event.inputs.timber_api_update_type == 'bug'}} | |
runs-on: ubuntu-latest | |
needs: [versions, create_timber_api_modio_pack] | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Setup .NET | |
uses: actions/setup-dotnet@v2 | |
- name: Find and Replace TIMBER_API_VERSION_PLACEHOLDER | |
uses: jacobtomlinson/gha-find-replace@v2 | |
with: | |
find: "TIMBER_API_VERSION_PLACEHOLDER" | |
replace: ${{ needs.versions.outputs.timber_api_leading_zero }} | |
regex: false | |
- name: Replace TIMBER_API_EXAMPLE_VERSION | |
uses: jacobtomlinson/gha-find-replace@v2 | |
with: | |
find: "TIMBER_API_EXAMPLE_VERSION" | |
replace: ${{ needs.versions.outputs.timber_api_example_leading_zero }} | |
regex: false | |
- name: Restore dependencies | |
run: dotnet restore | |
- name: Build TimberAPI.Common | |
run: dotnet build ${{env.timber_api_common_project_path}} --no-restore --configuration RELEASE -p:Version=${{ needs.versions.outputs.timber_api_leading_zero }} | |
- name: Build TimberAPI | |
run: dotnet build ${{env.timber_api_project_path}} --no-restore --configuration RELEASE -p:Version=${{ needs.versions.outputs.timber_api_leading_zero }} | |
- name: Test | |
run: dotnet test --no-build --verbosity normal | |
- name: .NET - Get Project File ReleaseVersion | |
id: get_version | |
uses: greenygh0st/net-proj-release-version@v2 | |
with: | |
PROJ_FILE: ${{env.timber_api_core_project_path}} | |
- name: Pack TimberAPI.Common | |
run: dotnet pack ${{env.timber_api_common_project_path}} --configuration RELEASE -p:Version=${{ needs.versions.outputs.timber_api_leading_zero }} | |
- name: Pack TimberAPI | |
run: dotnet pack ${{env.timber_api_project_path}} --configuration RELEASE -p:Version=${{ needs.versions.outputs.timber_api_leading_zero }} | |
- name: Upload TimberAPI.Common Build Artifact | |
uses: actions/[email protected] | |
with: | |
name: TimberAPI.Common_NugetPackage | |
path: ${{env.timber_api_common_nuget_path}}/*.nupkg | |
- name: Upload TimberAPI Build Artifact | |
uses: actions/[email protected] | |
with: | |
name: TimberAPI_NugetPackage | |
path: ${{env.timber_api_nuget_path}}/*.nupkg | |
- name: Push TimberAPI.Common NuGet Package | |
if: github.event.inputs.DoPrerelease != 'true' | |
run: dotnet nuget push ${{env.timber_api_common_nuget_path}}/*.nupkg -k ${{ secrets.TIMBERAPINUGETKEY }} -s https://api.nuget.org/v3/index.json --skip-duplicate | |
- name: Push TimberAPI NuGet Package | |
if: github.event.inputs.DoPrerelease != 'true' | |
run: dotnet nuget push ${{env.timber_api_nuget_path}}/*.nupkg -k ${{ secrets.TIMBERAPINUGETKEY }} -s https://api.nuget.org/v3/index.json --skip-duplicate | |
create_timber_api_modio_pack: | |
if: ${{ github.event.inputs.update_timber_api == 'true' }} | |
needs: [versions] | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Setup .NET | |
uses: actions/setup-dotnet@v2 | |
- name: Find and Replace TIMBER_API_VERSION_PLACEHOLDER | |
uses: jacobtomlinson/gha-find-replace@v2 | |
with: | |
find: "TIMBER_API_VERSION_PLACEHOLDER" | |
replace: ${{ needs.versions.outputs.timber_api_leading_zero }} | |
regex: false | |
- name: Find and Replace MINIMUN_GAME_VERSION_PLACEHOLDER | |
uses: jacobtomlinson/gha-find-replace@v2 | |
with: | |
find: "MINIMUN_GAME_VERSION_PLACEHOLDER" | |
replace: ${{ github.event.inputs.min_game_version }} | |
regex: false | |
- name: Replace TIMBER_API_EXAMPLE_VERSION | |
uses: jacobtomlinson/gha-find-replace@v2 | |
with: | |
find: "TIMBER_API_EXAMPLE_VERSION" | |
replace: ${{ needs.versions.outputs.timber_api_example_leading_zero }} | |
regex: false | |
- name: Restore dependencies | |
run: dotnet restore | |
- name: Build TimberAPICore | |
run: dotnet build ${{env.timber_api_core_project_path}} --no-restore --configuration RELEASE -p:Version=${{ needs.versions.outputs.timber_api_leading_zero }};SolutionDir=${{ github.workspace }} | |
- name: Build Loader | |
run: dotnet build ${{env.timber_api_loaders_project_path}} --no-restore --configuration RELEASE -p:Version=${{ needs.versions.outputs.timber_api_leading_zero }} | |
- name: Create TimberAPi folder | |
run: mkdir ${{ env.timber_api_package_folder }} | |
- name: Create TimberAPi dll folder | |
run: mkdir ${{ env.timber_api_package_dll_folder }} -p | |
- name: Create TimberAPi assets folder | |
run: mkdir ${{ env.timber_api_package_assets_folder }} -p | |
- name: Copy TimberApi.Common | |
run: cp ${{ env.timber_api_core_output_path }}/TimberApi.Common.dll ${{ env.timber_api_package_dll_folder }} | |
- name: Copy TimberApi.Core | |
run: cp ${{ env.timber_api_core_output_path }}/TimberApi.Core.dll ${{ env.timber_api_package_dll_folder }} | |
- name: Copy TimberApi | |
run: cp ${{ env.timber_api_core_output_path }}/TimberApi.dll ${{ env.timber_api_package_dll_folder }} | |
- name: Cope TimberApi.BepInEx.Plugin.Loader | |
run: cp ${{ env.timber_api_loaders_output_path }}/TimberApi.BepInEx.Plugin.Loader.dll ${{ env.timber_api_package_dll_folder }} | |
- name: Cope asset bundle | |
run: cp ${{ env.timber_api_assets_folder }}/timber_api ${{ env.timber_api_package_assets_folder }} | |
# | |
- name: Upload TimberAPI Mod.io Build Artifact | |
uses: actions/[email protected] | |
with: | |
name: TimberAPI_${{ needs.versions.outputs.timber_api_leading_zero }} | |
path: ${{ env.timber_api_package_folder }} | |
- name: Zip Release | |
uses: TheDoctor0/[email protected] | |
with: | |
filename: TimberAPI_${{ needs.versions.outputs.timber_api_leading_zero }}.zip | |
path: "TimberApi/core" | |
directory: ${{ env.timber_api_package_folder }} | |
- name: Read changelog | |
id: package | |
uses: juliangruber/read-file-action@v1 | |
with: | |
path: ./changelog.md | |
- name: regex match action | |
id: regex | |
uses: MeilCli/[email protected] | |
with: | |
regex_pattern: '(?<=### Changes\n).*?(?=##)' | |
regex_option: s | |
search_string: "${{ steps.package.outputs.content }}" | |
- name: extract metadata | |
id: metadata | |
run: | | |
GAME_ID=$(jq '.game_id' metadata.json) | |
MOD_ID=$(jq '.timber_api_mod_id' metadata.json) | |
echo "GAME=$GAME_ID" >> $GITHUB_OUTPUT | |
echo "MOD=$MOD_ID" >> $GITHUB_OUTPUT | |
- uses: nickelc/[email protected] | |
with: | |
token: ${{ secrets.MODIO_TOKEN }} | |
game: ${{ steps.metadata.outputs.GAME }} | |
mod: ${{ steps.metadata.outputs.MOD }} | |
version: ${{ needs.versions.outputs.timber_api_leading_zero }} | |
path: ${{ env.timber_api_package_folder }}/TimberAPI_${{ needs.versions.outputs.timber_api_leading_zero }}.zip | |
active: ${{ github.event.inputs.make_active_file_in_modio }} | |
changelog: "${{ steps.regex.outputs.matched_first }}" | |
create_timber_api_example_modio_pack: | |
if: ${{ github.event.inputs.update_timber_api_example == 'true' }} | |
needs: [versions] | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Setup .NET | |
uses: actions/setup-dotnet@v2 | |
- name: Replace TIMBER_API_VERSION | |
uses: jacobtomlinson/gha-find-replace@v2 | |
with: | |
find: "TIMBER_API_VERSION" | |
replace: ${{ needs.versions.outputs.timber_api_leading_zero }} | |
regex: false | |
- name: Replace TIMBER_API_EXAMPLE_VERSION | |
uses: jacobtomlinson/gha-find-replace@v2 | |
with: | |
find: "TIMBER_API_EXAMPLE_VERSION" | |
replace: ${{ needs.versions.outputs.timber_api_example_leading_zero }} | |
regex: false | |
- name: Restore dependencies | |
run: dotnet restore | |
- name: Build TimberAPIExample | |
run: dotnet build ${{env.timber_api_example_project_path}} --no-restore --configuration RELEASE -p:Version=${{ needs.versions.outputs.timber_api_example_leading_zero }} | |
- name: Copy TimberAPIExample.dll to package folder | |
run: cp ${{ env.timber_api_example_output_path }}/TimberAPIExample.dll ${{ env.timber_api_example_package_dir }}/TimberAPIExample/plugins | |
- name: Upload TimberAPIExample Mod.io Build Artifact | |
uses: actions/[email protected] | |
with: | |
name: TimberAPIExample_ModioPackage | |
path: ${{ env.timber_api_example_package_dir }} | |
update_version: | |
runs-on: ubuntu-latest | |
needs: [versions, create_timber_api_modio_pack, create_timber_api_example_modio_pack] | |
if: always() && (needs.create_timber_api_modio_pack.result == 'success' || needs.create_timber_api_example_modio_pack.result == 'success') | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Modify timber api version number | |
if: needs.create_timber_api_modio_pack.result == 'success' | |
uses: mingjun97/file-regex-replace@v1 | |
with: | |
regex: '(?<=TIMBER_API=).*' | |
replacement: '${{ needs.versions.outputs.timber_api }}' | |
include: 'project_versions.txt' | |
- name: Modify changelog | |
if: needs.create_timber_api_modio_pack.result == 'success' | |
uses: mingjun97/file-regex-replace@v1 | |
with: | |
regex: '## Unreleased' | |
replacement: | | |
## Unreleased | |
### Changes | |
## TimberAPI v${{ needs.versions.outputs.timber_api_leading_zero }} | |
include: 'changelog.md' | |
- name: Modify timber api example version number | |
if: needs.create_timber_api_example_modio_pack.result == 'success' | |
uses: mingjun97/file-regex-replace@v1 | |
with: | |
regex: '(?<=TIMBER_API_EXAMPLE=).*' | |
replacement: '${{ needs.versions.outputs.timber_api_example }}' | |
include: 'project_versions.txt' | |
- name: Commit updated version | |
uses: EndBug/add-and-commit@v9 | |
with: | |
message: "Updated versions" | |
default_author: github_actions | |
create_release: | |
needs: [versions, publish_timber_api_nuget, create_timber_api_modio_pack, create_timber_api_example_modio_pack, update_version] | |
if: always() | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
ref: main | |
- name: Read changelog | |
id: package | |
uses: juliangruber/read-file-action@v1 | |
with: | |
path: ./changelog.md | |
- name: Download TimberAPI mod.io artifact | |
uses: actions/download-artifact@v3 | |
if: needs.create_timber_api_modio_pack.result == 'success' | |
with: | |
name: TimberAPI_${{ needs.versions.outputs.timber_api_leading_zero }} | |
path: ${{ env.timber_api_package_folder }} | |
- name: Zip Release | |
uses: TheDoctor0/[email protected] | |
if: needs.create_timber_api_modio_pack.result == 'success' | |
with: | |
filename: TimberAPI_${{ needs.versions.outputs.timber_api_leading_zero }}_modio.zip | |
path: . | |
directory: ${{ env.timber_api_package_folder }} | |
- name: Download TimberAPI NuGet package | |
uses: actions/download-artifact@v3 | |
if: needs.publish_timber_api_nuget.result == 'success' | |
with: | |
name: TimberAPI_NugetPackage | |
path: . | |
- name: Download TimberAPI.Common NuGet package | |
uses: actions/download-artifact@v3 | |
if: needs.publish_timber_api_nuget.result == 'success' | |
with: | |
name: TimberAPI.Common_NugetPackage | |
path: . | |
- name: Download TimberAPI Exmaple mod.io artifact | |
uses: actions/download-artifact@v3 | |
if: needs.create_timber_api_example_modio_pack.result == 'success' | |
with: | |
name: TimberAPIExample_ModioPackage | |
path: ${{ env.timber_api_example_package_dir }} | |
- name: Zip TimberAPI Exmaple | |
uses: TheDoctor0/[email protected] | |
if: needs.create_timber_api_example_modio_pack.result == 'success' | |
with: | |
filename: TimberAPI_Example_${{ needs.versions.outputs.timber_api_example_leading_zero }}_modio.zip | |
path: . | |
directory: ${{ env.timber_api_example_package_dir }} | |
- name: regex match action | |
id: regex2 | |
uses: MeilCli/[email protected] | |
with: | |
regex_pattern: '## ${{ needs.versions.outputs.timber_api }}.*?(?=## \d)' | |
regex_option: s | |
search_string: "${{ steps.package.outputs.content }}" | |
- name: Release | |
uses: softprops/action-gh-release@v1 | |
with: | |
tag_name: v${{ needs.versions.outputs.timber_api_leading_zero }} | |
name: v${{ needs.versions.outputs.timber_api_leading_zero }} | |
body: ${{ steps.regex2.outputs.matched_first }} | |
draft: false | |
prerelease: false | |
files: | | |
**/TimberAPI_${{ needs.versions.outputs.timber_api_leading_zero }}_modio.zip | |
**/TimberAPI_Example_${{ needs.versions.outputs.timber_api_example_leading_zero }}_modio.zip | |
**/*.nupkg | |
token: ${{ secrets.GITHUB_TOKEN }} |