Skip to content

Commit

Permalink
Merge pull request #486 from TimeWarpEngineering/Cramer/2024-10-18/Pages
Browse files Browse the repository at this point in the history
build: Update publish-documentation workflow
  • Loading branch information
StevenTCramer authored Oct 18, 2024
2 parents 801e2f7 + a4ed308 commit 05bb1db
Show file tree
Hide file tree
Showing 3 changed files with 131 additions and 111 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/ci-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@ name: Build and Test

on:
pull_request:
paths:
- 'Source/**'
- 'Tests/**'
- '.github/workflows/ci-build.yml'
- '*.props'
- '*.targets'
workflow_dispatch:

env:
Expand Down
31 changes: 18 additions & 13 deletions .github/workflows/publish-documentation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ on:
env:
DOTNET_NOLOGO: true # Disable the .NET logo in the console output
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true # Disable the .NET first time experience to skip caching NuGet packages and speed up the build
DOTNET_CLI_TELEMETRY_OPTOUT: true
DOTNET_CLI_TELEMETRY_OPTOUT: true

# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
Expand All @@ -22,33 +22,38 @@ permissions:
# Allow one concurrent deployment
concurrency:
group: "pages"
cancel-in-progress: true
cancel-in-progress: false

jobs:
deploy:
publish-docs:
defaults:
run:
shell: pwsh
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
url: ${{ steps.deployment.outputs.page_url }}
runs-on: windows-latest
steps:
- run: echo "πŸŽ‰ The job was automatically triggered by a ${{ github.event_name }} event."
- run: echo "🐧 This job is now running on a ${{ runner.os }} server hosted by GitHub!"
- run: echo "πŸ”Ž The name of your branch is ${{ github.ref }} and your repository is ${{ github.repository }}."

- name: Check out repository code
uses: actions/checkout@v3
uses: actions/checkout@v4
- run: echo "πŸ’‘ The ${{ github.repository }} repository has been cloned to the runner."

- name: List files in the repository
run: |
ls ${{ github.workspace }}
- name: Setup DocFX
uses: crazy-max/ghaction-chocolatey@v2
- name: Dotnet Setup
uses: actions/setup-dotnet@v4
with:
args: install docfx
dotnet-version: 8.x

# - name: Setup DocFX
# uses: crazy-max/ghaction-chocolatey@v2
# with:
# args: install docfx

- name: Setup DocFX
run: dotnet tool update --global docfx

- name: Run Build Script
run: ./.github/workflows/build.ps1
Expand All @@ -62,13 +67,13 @@ jobs:
- name: Setup Pages
uses: actions/configure-pages@v2
- name: Upload artifact
uses: actions/upload-pages-artifact@v1
uses: actions/upload-pages-artifact@v3
with:
# Upload entire repository
path: './Documentation/_site'

- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v1
uses: actions/deploy-pages@v4

- run: echo "🍏 This job's status is ${{ job.status }}."
205 changes: 107 additions & 98 deletions .github/workflows/release-build.yml
Original file line number Diff line number Diff line change
@@ -1,98 +1,107 @@
name: Build and Deploy

on:
push:
branches:
- master
workflow_dispatch:

env:
DOTNET_NOLOGO: true # Disable the .NET logo in the console output
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true # Disable the .NET first time experience to skip caching NuGet packages and speed up the build
DOTNET_CLI_TELEMETRY_OPTOUT: true
NUGET_AUTH_TOKEN: ${{secrets.PUBLISH_TO_NUGET_ORG}} # <-- This is the token for the GitHub account you want to use.

jobs:
build:
runs-on: ubuntu-latest
defaults:
run:
shell: pwsh
steps:
- run: echo "πŸŽ‰ The job was automatically triggered by a ${{ github.event_name }} event."
- run: echo "🐧 This job is now running on a ${{ runner.os }} server hosted by GitHub!"
- run: echo "πŸ”Ž The name of your branch is ${{ github.ref }} and your repository is ${{ github.repository }}."

- name: Check out repository code
uses: actions/checkout@v4
- run: echo "πŸ’‘ The ${{ github.repository }} repository has been cloned to the runner."

- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.0.403'

- name: Run BuildNuGets.ps1
run: |
.\BuildNuGets.ps1
- name: Publish TimeWarp.State
run: |
cd Source/TimeWarp.State/bin/Release
dotnet nuget push TimeWarp.State.*.nupkg --skip-duplicate --source https://api.nuget.org/v3/index.json --api-key ${{secrets.PUBLISH_TO_NUGET_ORG}}
# Assuming snupkg files are in the same directory and are named correspondingly
- name: Publish TimeWarp.State.Plus
run: |
cd Source/TimeWarp.State.Plus/bin/Release
dotnet nuget push TimeWarp.State.Plus.*.nupkg --skip-duplicate --source https://api.nuget.org/v3/index.json --api-key ${{secrets.PUBLISH_TO_NUGET_ORG}}
# Assuming snupkg files are in the same directory and are named correspondingly
- name: Publish TimeWarp.State.Policies
run: |
cd Source/TimeWarp.State.Policies/bin/Release
dotnet nuget push TimeWarp.State.Policies.*.nupkg --skip-duplicate --source https://api.nuget.org/v3/index.json --api-key ${{secrets.PUBLISH_TO_NUGET_ORG}}
# Assuming snupkg files are in the same directory and are named correspondingly
- name: Extract version from Directory.Build.props
id: extract_version
run: |
[xml]$xml = Get-Content -Path "Directory.Build.props"
$version = $xml.Project.PropertyGroup.TimeWarpStateVersion
echo "Extracted version: $version"
echo "::set-output name=VERSION::$version"
shell: pwsh

- name: Tag commit with version
run: |
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
$version = "${{ steps.extract_version.outputs.VERSION }}" -replace "\+.*$",""
git tag -a $version -m "Release $version"
git push origin $version
shell: pwsh

- name: Check if version is not a beta
id: check_beta
run: |
$version = "${{ steps.extract_version.outputs.VERSION }}"
$isBeta = $version -match "-beta"
echo "IsBeta=$isBeta"
# Setting output that indicates whether it's a beta version
echo "::set-output name=IS_BETA::$isBeta"
shell: pwsh

- name: Create GitHub Release
if: steps.check_beta.outputs.IS_BETA == 'False'
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.extract_version.outputs.VERSION }}
release_name: Release ${{ steps.extract_version.outputs.VERSION }}
draft: false
prerelease: false
body: "Update Release notes on GitHub"


- run: echo "🍏 This job's status is ${{ job.status }}."
name: Build and Deploy

on:
push:
branches:
- master
paths:
- 'Source/**'
- 'Tests/**'
- '.github/workflows/release-build.yml'
- 'Directory.Build.props'
- '*.props'
- '*.targets'
release:
types: [created]
workflow_dispatch:

env:
DOTNET_NOLOGO: true
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
DOTNET_CLI_TELEMETRY_OPTOUT: true
NUGET_AUTH_TOKEN: ${{secrets.PUBLISH_TO_NUGET_ORG}}

jobs:
build:
runs-on: ubuntu-latest
defaults:
run:
shell: pwsh
steps:
- run: echo "πŸŽ‰ The job was automatically triggered by a ${{ github.event_name }} event."
- run: echo "🐧 This job is now running on a ${{ runner.os }} server hosted by GitHub!"
- run: echo "πŸ”Ž The name of your branch is ${{ github.ref }} and your repository is ${{ github.repository }}."

- name: Check out repository code
uses: actions/checkout@v4
- run: echo "πŸ’‘ The ${{ github.repository }} repository has been cloned to the runner."

- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.0.403'

- name: Run BuildNuGets.ps1
run: |
.\BuildNuGets.ps1
- name: Publish TimeWarp.State
run: |
cd Source/TimeWarp.State/bin/Release
dotnet nuget push TimeWarp.State.*.nupkg --skip-duplicate --source https://api.nuget.org/v3/index.json --api-key ${{secrets.PUBLISH_TO_NUGET_ORG}}
# Assuming snupkg files are in the same directory and are named correspondingly
- name: Publish TimeWarp.State.Plus
run: |
cd Source/TimeWarp.State.Plus/bin/Release
dotnet nuget push TimeWarp.State.Plus.*.nupkg --skip-duplicate --source https://api.nuget.org/v3/index.json --api-key ${{secrets.PUBLISH_TO_NUGET_ORG}}
# Assuming snupkg files are in the same directory and are named correspondingly
- name: Publish TimeWarp.State.Policies
run: |
cd Source/TimeWarp.State.Policies/bin/Release
dotnet nuget push TimeWarp.State.Policies.*.nupkg --skip-duplicate --source https://api.nuget.org/v3/index.json --api-key ${{secrets.PUBLISH_TO_NUGET_ORG}}
# Assuming snupkg files are in the same directory and are named correspondingly
- name: Extract version from Directory.Build.props
id: extract_version
run: |
[xml]$xml = Get-Content -Path "Directory.Build.props"
$version = $xml.Project.PropertyGroup.TimeWarpStateVersion
echo "Extracted version: $version"
echo "::set-output name=VERSION::$version"
shell: pwsh

- name: Tag commit with version
run: |
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
$version = "${{ steps.extract_version.outputs.VERSION }}" -replace "\+.*$",""
git tag -a $version -m "Release $version"
git push origin $version
shell: pwsh

- name: Check if version is not a beta
id: check_beta
run: |
$version = "${{ steps.extract_version.outputs.VERSION }}"
$isBeta = $version -match "-beta"
echo "IsBeta=$isBeta"
# Setting output that indicates whether it's a beta version
echo "::set-output name=IS_BETA::$isBeta"
shell: pwsh

- name: Create GitHub Release
if: steps.check_beta.outputs.IS_BETA == 'False'
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.extract_version.outputs.VERSION }}
release_name: Release ${{ steps.extract_version.outputs.VERSION }}
draft: false
prerelease: false
body: "Update Release notes on GitHub"


- run: echo "🍏 This job's status is ${{ job.status }}."

0 comments on commit 05bb1db

Please sign in to comment.