-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rework versioning system to use Minver (#86)
* Fix redundant tmp variable * Add MinVer to generate version numbers * Update workflows to use Minver
- Loading branch information
Showing
5 changed files
with
193 additions
and
114 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,132 +3,60 @@ name: Publish (Nightly) | |
on: | ||
schedule: | ||
- cron: "0 0 * * *" | ||
|
||
jobs: | ||
|
||
setup: | ||
if: github.repository == 'Kaioru/Edelstein' | ||
runs-on: ubuntu-latest | ||
|
||
name: Setup | ||
runs-on: ubuntu-latest | ||
|
||
outputs: | ||
should_run: ${{ steps.should_run.outputs.should_run }} | ||
date: ${{ steps.date.outputs.date }} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Check current date | ||
id: date | ||
run: echo "date=$(date +'%Y%m%d')" >> $GITHUB_OUTPUT | ||
- id: should_run | ||
continue-on-error: true | ||
name: Check for new commits | ||
if: ${{ github.event_name == 'schedule' }} | ||
run: test -z $(git rev-list --after="24 hours" ${{ github.sha }}) && echo "should_run=false" >> $GITHUB_OUTPUT | ||
- uses: actions/checkout@v4 | ||
- id: should_run | ||
continue-on-error: true | ||
name: Check for new commits | ||
if: ${{ github.event_name == 'schedule' }} | ||
run: test -z $(git rev-list --after="24 hours" ${{ github.sha }}) && echo "should_run=false" >> $GITHUB_OUTPUT | ||
|
||
publish_nuget: | ||
versioning: | ||
needs: setup | ||
if: ${{ needs.setup.outputs.should_run != 'false' }} | ||
|
||
name: Versioning | ||
runs-on: ubuntu-latest | ||
name: Publish to Github NuGet Registry | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Setup .NET | ||
uses: actions/setup-dotnet@v3 | ||
with: | ||
dotnet-version: '7.0.x' | ||
- uses: actions/cache@v1 | ||
with: | ||
path: ~/.nuget/packages | ||
key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }} | ||
restore-keys: | | ||
${{ runner.os }}-nuget- | ||
- run: dotnet restore --locked-mode | ||
- name: Pack | ||
run: dotnet pack --configuration Release --version-suffix "nightly.${{ needs.setup.outputs.date }}" --output artifacts | ||
- name: Publish | ||
run: dotnet nuget push artifacts/*.nupkg --api-key ${{ secrets.GITHUB_TOKEN }} --source "https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json" | ||
- name: Add VERSION, COMMIT, LICENSE, and README files | ||
run: | | ||
echo "nightly.${{ needs.setup.outputs.date }}" > artifacts/VERSION | ||
echo ${{ github.sha }} > artifacts/COMMIT | ||
cp LICENSE artifacts | ||
cp README.md artifacts | ||
- name: Compress | ||
run: cd artifacts; zip ../packages-nightly.${{ needs.setup.outputs.date }}.zip *; cd .. | ||
- name: Store artifacts | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: packages-nightly.${{ needs.setup.outputs.date }} | ||
path: packages-nightly.${{ needs.setup.outputs.date }}.zip | ||
fetch-depth: 0 | ||
|
||
publish_artifacts: | ||
needs: setup | ||
if: ${{ needs.setup.outputs.should_run != 'false' }} | ||
strategy: | ||
matrix: | ||
runtime: [win-x64, win-arm64, osx-x64, osx-arm64, linux-x64, linux-arm64] | ||
runs-on: ubuntu-latest | ||
name: Publish artifacts (${{ matrix.runtime }}) | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Setup .NET | ||
uses: actions/setup-dotnet@v3 | ||
with: | ||
dotnet-version: '7.0.x' | ||
- uses: actions/cache@v1 | ||
with: | ||
path: ~/.nuget/packages | ||
key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }} | ||
restore-keys: | | ||
${{ runner.os }}-nuget- | ||
- run: dotnet restore --locked-mode | ||
- name: Install EntityFramework Core tools | ||
run: dotnet tool install --global dotnet-ef | ||
- name: Publish (apps) | ||
run: | | ||
for project in src/app/*/ ; do | ||
dotnet publish $project -c Release -r ${{ matrix.runtime }} --output artifacts-${{ matrix.runtime }} -p:PublishReadyToRun=true -p:PublishSingleFile=true -p:SelfContained=true | ||
done | ||
- name: Bundle migrations (scripts) | ||
run: | | ||
dotnet ef migrations script --project src/common/Edelstein.Common.Database/ --output artifacts-${{ matrix.runtime }}/migrate-01-gameplay.sql --idempotent | ||
dotnet ef migrations script --project src/common/Edelstein.Common.Services.Auth/ --output artifacts-${{ matrix.runtime }}/migrate-02-auth.sql --idempotent | ||
dotnet ef migrations script --project src/common/Edelstein.Common.Services.Server/ --output artifacts-${{ matrix.runtime }}/migrate-03-server.sql --idempotent | ||
dotnet ef migrations script --project src/common/Edelstein.Common.Services.Social/ --output artifacts-${{ matrix.runtime }}/migrate-04-social.sql --idempotent | ||
- name: Add VERSION, COMMIT, LICENSE, and README files | ||
run: | | ||
echo "nightly.${{ needs.setup.outputs.date }}" > artifacts-${{ matrix.runtime }}/VERSION | ||
echo ${{ github.sha }} > artifacts-${{ matrix.runtime }}/COMMIT | ||
cp LICENSE artifacts-${{ matrix.runtime }} | ||
cp README.md artifacts-${{ matrix.runtime }} | ||
- name: Create data, scripts, and plugins directories | ||
run: | | ||
mkdir artifacts-${{ matrix.runtime }}/data | ||
mkdir artifacts-${{ matrix.runtime }}/scripts | ||
mkdir artifacts-${{ matrix.runtime }}/plugins | ||
- name: Publish (plugins) | ||
run: | | ||
for project in src/plugin/*/ ; do | ||
dotnet publish $project -c Release --output artifacts-${{ matrix.runtime }}/plugins/$(basename $project) | ||
done | ||
- name: Compress | ||
run: cd artifacts-${{ matrix.runtime }}; zip -r ../server-${{ matrix.runtime }}-nightly.${{ needs.setup.outputs.date }}.zip . ; cd .. | ||
- name: Store artifacts | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: server-${{ matrix.runtime }}-nightly.${{ needs.setup.outputs.date }} | ||
path: server-${{ matrix.runtime }}-nightly.${{ needs.setup.outputs.date }}.zip | ||
|
||
publish_release: | ||
needs: [setup, publish_artifacts] | ||
- name: Install Minver | ||
run: dotnet tool install --global minver-cli --version 4.3.0 | ||
|
||
- name: Calculating version | ||
id: version | ||
run: echo "version=$(minver -m 1.0 -p preview -v e)" >> $GITHUB_OUTPUT | ||
|
||
publish: | ||
needs: [setup, versioning] | ||
if: ${{ needs.setup.outputs.should_run != 'false' }} | ||
|
||
name: Publish | ||
runs-on: ubuntu-latest | ||
name: Publish to Github releases | ||
|
||
steps: | ||
- name: Download artifacts | ||
uses: actions/download-artifact@v3 | ||
- uses: "marvinpinto/[email protected]" | ||
with: | ||
repo_token: "${{ secrets.GITHUB_TOKEN }}" | ||
automatic_release_tag: "nightly" | ||
prerelease: true | ||
title: "Nightly Build (${{ needs.setup.outputs.date }})" | ||
files: "*/*.zip" | ||
- uses: ./.github/workflows/publish.yml | ||
with: | ||
version: ${{ needs.versioning.outputs.version }} | ||
tag: nightly | ||
prerelease: true | ||
draft: false |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,151 @@ | ||
on: | ||
workflow_call: | ||
inputs: | ||
version: | ||
required: true | ||
type: string | ||
tag: | ||
type: string | ||
prerelease: | ||
required: true | ||
default: false | ||
type: boolean | ||
draft: | ||
required: true | ||
default: true | ||
type: boolean | ||
|
||
jobs: | ||
|
||
publish_nuget: | ||
name: Publish to Github Packages | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Setup .NET | ||
uses: actions/setup-dotnet@v3 | ||
with: | ||
dotnet-version: '7.0.x' | ||
|
||
- uses: actions/cache@v1 | ||
with: | ||
path: ~/.nuget/packages | ||
key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }} | ||
restore-keys: | | ||
${{ runner.os }}-nuget- | ||
- name: Restore | ||
run: dotnet restore --locked-mode | ||
|
||
- name: Pack | ||
run: dotnet pack --configuration Release --output artifacts /p:PackageVersion=${{ github.event.inputs.version }} | ||
|
||
- name: Publish | ||
run: dotnet nuget push artifacts/*.nupkg --api-key ${{ secrets.GITHUB_TOKEN }} --source "https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json" | ||
|
||
- name: Add VERSION, COMMIT, LICENSE, and README files | ||
run: | | ||
echo ${{ github.event.inputs.version }} > artifacts/VERSION | ||
echo ${{ github.sha }} > artifacts/COMMIT | ||
cp LICENSE artifacts | ||
cp README.md artifacts | ||
- name: Compress | ||
run: cd artifacts; zip ../packages-${{ github.event.inputs.version }}.zip *; cd .. | ||
|
||
- name: Store artifacts | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: packages-${{ github.event.inputs.version }} | ||
path: packages-${{ github.event.inputs.version }}.zip | ||
|
||
publish_artifact: | ||
strategy: | ||
matrix: | ||
runtime: [win-x64, win-arm64, osx-x64, osx-arm64, linux-x64, linux-arm64] | ||
|
||
name: Publish artifacts (${{ matrix.runtime }}) | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Setup .NET | ||
uses: actions/setup-dotnet@v3 | ||
with: | ||
dotnet-version: '7.0.x' | ||
|
||
- uses: actions/cache@v1 | ||
with: | ||
path: ~/.nuget/packages | ||
key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }} | ||
restore-keys: | | ||
${{ runner.os }}-nuget- | ||
- name: Restore | ||
run: dotnet restore --locked-mode | ||
|
||
- name: Install EntityFramework Core tools | ||
run: dotnet tool install --global dotnet-ef | ||
|
||
- name: Publish (apps) | ||
run: | | ||
for project in src/app/*/ ; do | ||
dotnet publish $project -c Release -r ${{ matrix.runtime }} --output artifacts-${{ matrix.runtime }} -p:PublishReadyToRun=true -p:PublishSingleFile=true -p:SelfContained=true | ||
done | ||
- name: Bundle migrations (scripts) | ||
run: | | ||
dotnet ef migrations script --project src/common/Edelstein.Common.Database/ --output artifacts-${{ matrix.runtime }}/migrate-01-gameplay.sql --idempotent | ||
dotnet ef migrations script --project src/common/Edelstein.Common.Services.Auth/ --output artifacts-${{ matrix.runtime }}/migrate-02-auth.sql --idempotent | ||
dotnet ef migrations script --project src/common/Edelstein.Common.Services.Server/ --output artifacts-${{ matrix.runtime }}/migrate-03-server.sql --idempotent | ||
dotnet ef migrations script --project src/common/Edelstein.Common.Services.Social/ --output artifacts-${{ matrix.runtime }}/migrate-04-social.sql --idempotent | ||
- name: Add VERSION, COMMIT, LICENSE, and README files | ||
run: | | ||
echo ${{ github.event.inputs.version }} > artifacts-${{ matrix.runtime }}/VERSION | ||
echo ${{ github.sha }} > artifacts-${{ matrix.runtime }}/COMMIT | ||
cp LICENSE artifacts-${{ matrix.runtime }} | ||
cp README.md artifacts-${{ matrix.runtime }} | ||
- name: Create data, scripts, and plugins directories | ||
run: | | ||
mkdir artifacts-${{ matrix.runtime }}/data | ||
mkdir artifacts-${{ matrix.runtime }}/scripts | ||
mkdir artifacts-${{ matrix.runtime }}/plugins | ||
- name: Publish (plugins) | ||
run: | | ||
for project in src/plugin/*/ ; do | ||
dotnet publish $project -c Release --output artifacts-${{ matrix.runtime }}/plugins/$(basename $project) | ||
done | ||
- name: Compress artifacts | ||
run: cd artifacts-${{ matrix.runtime }}; zip -r ../server-${{ matrix.runtime }}-${{ github.event.inputs.version }}.zip . ; cd .. | ||
|
||
- name: Store artifacts | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: server-${{ matrix.runtime }}-${{ github.event.inputs.version }} | ||
path: server-${{ matrix.runtime }}-${{ github.event.inputs.version }}.zip | ||
|
||
publish_release: | ||
needs: [publish_artifacts] | ||
|
||
name: Publish to Github releases | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Download artifacts | ||
uses: actions/download-artifact@v3 | ||
|
||
- uses: "marvinpinto/[email protected]" | ||
with: | ||
repo_token: "${{ secrets.GITHUB_TOKEN }}" | ||
automatic_release_tag: "${{ github.event.inputs.tag }}" | ||
prerelease: ${{ github.event.inputs.prerelease }} | ||
draft: ${{ github.event.inputs.draft }} | ||
title: "${{ github.event.inputs.version }}" | ||
files: "*/*.zip" |
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
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