Skip to content

Commit

Permalink
added workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
danzuep committed Jan 23, 2024
1 parent d93a0a5 commit e58d3a8
Show file tree
Hide file tree
Showing 12 changed files with 444 additions and 32 deletions.
22 changes: 22 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates

version: 2
updates:
# Maintain dependencies for GitHub Actions
- package-ecosystem: "github-actions"
directory: "/.github/workflows"
schedule:
interval: "monthly"
# Disable future pull requests for GitHub Actions dependencies
open-pull-requests-limit: 1

# Maintain dependencies for NuGet
- package-ecosystem: "nuget"
directory: "/"
schedule:
interval: "monthly"
# Disable future pull requests for NuGet dependencies
open-pull-requests-limit: 1
17 changes: 17 additions & 0 deletions .github/stale.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Number of days of inactivity before an issue becomes stale
daysUntilStale: 90
# Number of days of inactivity before a stale issue is closed
daysUntilClose: 30
# Issues with these labels will never be considered stale
exemptLabels:
- pinned
- security
# Label to use when marking an issue as stale
staleLabel: wontfix
# Comment to post when marking an issue as stale. Set to `false` to disable
markComment: >
This issue has been automatically marked as stale because it has not had
recent activity. It will be closed if no further activity occurs. Thank you
for your contributions.
# Comment to post when closing a stale issue. Set to `false` to disable
closeComment: false
78 changes: 78 additions & 0 deletions .github/workflows/_android.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
name: 🚀 Publish Android package
run-name: Publish Android package

on:
workflow_call:
inputs:
projectFile:
description: 'The project file path'
required: true
type: string
version:
description: 'Package version'
required: true
type: string
environment:
description: 'The publish environment'
default: release
type: string

env:
DotNetVersion: 8.0.x
DotNetTarget: net8.0

jobs:
deploy:
name: Android
runs-on: ubuntu-latest
environment: ${{ inputs.environment }}
steps:
# https://github.com/actions/checkout#fetch-all-history-for-all-tags-and-branches
- name: Checkout the source repository from Git
uses: actions/checkout@v4

# https://github.com/actions/setup-dotnet
- name: Get .NET externals
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ env.DotNetVersion }}
dotnet-quality: 'ga'

- name: Install .NET MAUI
shell: pwsh
run: |
echo ".NET Version: ${{ env.DotNetVersion }}";
dotnet --version;
dotnet workload install maui-android;
dotnet workload list;
- name: Publish Android package
run: |
echo "Project File: $projectFile";
echo "Project Version: $buildVersion";
echo "Target Framework: $targetFramework";
dotnet publish $projectFile /p:Version=$buildVersion -f $targetFramework --nologo;
env:
projectFile: '${{ inputs.projectFile }}'
buildVersion: '${{ inputs.version }}'
targetFramework: "${{ env.DotNetTarget }}-android"

- name: Markdown workflow job summary
run: |
repositoryName=$(basename '${{ github.repository }}')
echo "### $repositoryName ${{ inputs.version }} apk published" >> $GITHUB_STEP_SUMMARY
# https://github.com/actions/upload-artifact
- name: Upload apk artifacts
uses: actions/upload-artifact@v4
with:
path: "publish/*-Signed.apk"

metadata:
name: Fastlane
runs-on: ubuntu-latest
environment: ${{ inputs.environment }}
steps:
- uses: actions/checkout@v4
- name: Statically validate Fastlane metadata for Android
uses: ashutoshgngwr/validate-fastlane-supply-metadata@v2
109 changes: 109 additions & 0 deletions .github/workflows/_build-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
name: "Build"

on:
workflow_call:
inputs:
project-name:
description: 'The name of the project'
required: true
type: string
project-version:
description: 'The project version'
required: true
type: string
project-output:
description: "Path of the publish output directory"
default: "publish"
type: string
name:
description: 'Artifact name'
default: 'github-pages'
type: string
outputs:
project_file:
description: 'The project file name'
value: ${{ jobs.build_website.outputs.project-file }}
page_url:
description: 'The webpage URL'
value: ${{ jobs.deploy.outputs.page_url }}

jobs:
build_website:
name: Build
runs-on: 'ubuntu-latest'
env:
PROJECT_PATH: "./${{ inputs.project-name }}/${{ inputs.project-name }}.csproj"
NET_VERSION: '8.x'

outputs:
project-file: ${{ env.PROJECT_PATH }}

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

# https://github.com/actions/setup-dotnet
- name: Get .NET ${{ env.NET_VERSION }} externals
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ env.NET_VERSION }}
dotnet-quality: 'ga'

# https://github.com/dotnet/runtime/blob/main/src/mono/wasm/features.md
- name: Install .NET WebAssembly workload
run: dotnet workload install wasm-tools;
# dotnet workload restore;

- name: Restore project dependencies
run: |
dotnet restore ${{ env.PROJECT_PATH }}
dotnet publish ${{ env.PROJECT_PATH }} -c:Release -p:Version=${{ inputs.project-version }} -o:${{ inputs.project-output }} --no-restore --nologo
# "https://learn.microsoft.com/en-us/aspnet/core/blazor/host-and-deploy/webassembly?view=aspnetcore-8.0#github-pages"
# "To deploy folders starting with underscore, add an empty .nojekyll file to the Git branch."
- name: Add .nojekyll file
run: touch "${{ inputs.project-output }}/wwwroot/.nojekyll"

# # changes the base-tag in index.html from '/' to match GitHub Pages repository subdirectory
# - name: Change base-tag in index.html from / to the repository name
# run: |
# repositoryName=$(basename '${{ github.repository }}')
# echo "Repository name: $repositoryName"
# sed -i 's/<base href="\/" \/>/<base href="\/$repositoryName\/" \/>/g' "${{ inputs.project-output }}/wwwroot/index.html"

- name: Setup Pages
uses: actions/configure-pages@v4

# https://github.com/actions/upload-pages-artifact
- name: Upload GitHub Pages artifact for web
uses: actions/upload-pages-artifact@v3
with:
path: "${{ inputs.project-output }}/wwwroot"

# Deploy job
deploy:
name: Deploy App to GitHub Pages
# Add a dependency to the build job
needs:
- build_website

# Grant GITHUB_TOKEN the permissions required to make a Pages deployment
permissions:
pages: write # to deploy to Pages
id-token: write # to verify the deployment originates from an appropriate source

# Deploy to the github-pages environment
environment:
name: ${{ inputs.name }}
url: ${{ steps.deployment.outputs.page_url }}

outputs:
page_url: ${{ steps.deployment.outputs.page_url }}

# Specify runner + deployment step
runs-on: ubuntu-latest
steps:
# https://github.com/actions/deploy-pages
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4 # or specific "vX.X.X" version tag for this action
119 changes: 119 additions & 0 deletions .github/workflows/_version.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
name: 🧬 Version
run-name: Get version with GitVersion

on:
workflow_call:
inputs:
appProjectName:
description: 'The repository app project name'
required: false
type: string
outputs:
projectName:
description: 'The repository app project name'
value: ${{ jobs.version.outputs.projectName }}
projectFile:
description: 'The repository app project file'
value: ${{ jobs.version.outputs.projectFile }}
semVer:
description: 'GitVersion semantic version'
value: ${{ jobs.version.outputs.semVer }}

jobs:
version:
name: GitVersion
runs-on: 'ubuntu-latest'

outputs: # alternative usage: $GitVersion_<outputName>
semVer: ${{ steps.gitversion.outputs.semVer }}
fullSemVer: ${{ steps.gitversion.outputs.fullSemVer }}
nuGetVersion: ${{ steps.gitversion.outputs.nuGetVersion }}
majorMinorPatch: ${{ steps.gitversion.outputs.majorMinorPatch }}
preReleaseLabel: ${{ steps.gitversion.outputs.preReleaseLabel }}
commitDate: ${{ steps.gitversion.outputs.commitDate }}
projectName: ${{ steps.metadata.outputs.projectName }}
projectFile: ${{ steps.metadata.outputs.projectFile }}

steps:
# https://github.com/actions/checkout#fetch-all-history-for-all-tags-and-branches
- name: Fetch all tags and branches for GitVersion
uses: actions/checkout@v4
with:
fetch-depth: 0

# https://github.com/GitTools/actions/blob/main/docs/examples/github/gitversion/setup/usage-examples.md#example-1
- name: Set up GitVersion
uses: gittools/actions/gitversion/setup@v0
with:
versionSpec: '5.x'

# https://github.com/GitTools/actions/blob/main/docs/examples/github/gitversion/execute/usage-examples.md#example-5
# For a list of all GitVersion Version Variables, see https://gitversion.net/docs/reference/variables
# pwsh> dotnet-gitversion | ConvertFrom-Json
- name: Use GitVersion to determine version
id: gitversion # e.g. steps.gitversion.outputs.<outputName>
uses: gittools/actions/gitversion/execute@v0

- run: |
echo 'Get the repository project name.'
projectName=$(basename '${{ github.repository }}')
echo "Repository name: $projectName"
echo "projectName=${projectName}" >> $GITHUB_ENV
echo "App project name: ${{ inputs.appProjectName }}"
- run: |
echo "Generate release notes from the Git commit log."
echo "## $projectName" > release-notes.txt
git log --pretty=format:"- %s" >> release-notes.txt
- run: |
echo 'Save the project name to a file.'
echo "projectName=${projectName}" > version.txt
- run: |
echo 'Save the repository solution file path'
shopt -s globstar
for solution in ./*.sln; do
echo "Solution file: $solution"
echo "solutionFile=${solution}" >> version.txt
done
- id: metadata
shell: bash
run: |
echo 'Save the main app project file path'
echo "projectName=${projectName}" >> $GITHUB_OUTPUT
searchName="${{ inputs.appProjectName }}"
for project in ./**/*.csproj; do
echo "Project file: $project"
if [[ $project == *"${searchName}"* ]]; then
echo "projectFile=${project}" >> $GITHUB_OUTPUT
fi
echo "projectFiles=${project}" >> version.txt
done
- run: |
echo 'Save the GitVersion environment variables to a file.'
for var in $(env | grep '^GitVersion_' | cut -d= -f1); do
echo "$var=${!var}" >> version.txt
done
# https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#adding-a-job-summary
- name: Markdown workflow job summary
run: |
echo '### ${{ env.workflowVersion }} build summary' >> $GITHUB_STEP_SUMMARY
echo "Repository: ${{ github.repository }}" >> $GITHUB_STEP_SUMMARY
echo "Branch: ${{ github.ref }}" >> $GITHUB_STEP_SUMMARY
echo 'Commit Date: ${{ steps.gitversion.outputs.commitDate }}' >> $GITHUB_STEP_SUMMARY
echo 'Full Semantic Version: ${{ steps.gitversion.outputs.fullSemVer }}' >> $GITHUB_STEP_SUMMARY
echo 'Pre-release Label: ${{ steps.gitversion.outputs.preReleaseLabel }}' >> $GITHUB_STEP_SUMMARY
env:
workflowVersion: '${{ steps.metadata.outputs.projectName }} version ${{ steps.gitversion.outputs.semVer }}'

# https://github.com/actions/upload-artifact
- name: Upload version artifacts
uses: actions/upload-artifact@v4
with:
path: |
version.txt
release-notes.txt
15 changes: 15 additions & 0 deletions .github/workflows/development.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: Development
run-name: Get version and build release notes

on:
workflow_dispatch:

# Cancel any other running workflows with the same ID
concurrency:
group: cd-release-${{ github.ref }}
cancel-in-progress: true

# https://docs.github.com/en/actions/using-workflows/reusing-workflows
jobs:
version:
uses: ./.github/workflows/_version.yml
Loading

0 comments on commit e58d3a8

Please sign in to comment.