Skip to content

Commit

Permalink
feat: optimize release workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
aochmann committed Mar 1, 2021
1 parent 24753ef commit 2f6ad3a
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 139 deletions.
66 changes: 11 additions & 55 deletions .github/workflows/release-github.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,40 +2,23 @@ name: (NuGet) GitHub Packages Release

on:
workflow_run:
workflows: [ "Changelog generator" ]
workflows: [ "Build" ]
types:
- completed
jobs:
github_packages_release:
name: GitHub Packages Release
if: ${{ github.event.workflow_run.conclusion == 'success' }}
runs-on: windows-latest
if: ${{ github.event.workflow_run.conclusion == 'success' && github.event_name != 'pull_request' }}
runs-on: ubuntu-latest
env:
# Dotnet Setup
DOTNET_VERSION: 3.1.401

# Stop wasting time caching packages
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true

# Disable sending usage data to Microsoft
DOTNET_CLI_TELEMETRY_OPTOUT: true

# Nuget Setup
NUGET_VERSION: 'latest'
NUGET_OUTPUT: output

# Solution Setup
CONFIG: 'Release'
SOLUTION: 'Source\Cogworks.Essentials.sln'
VERSION: '1.0.0'

# GitHub Packages Feed settings
GITHUB_USER: thecogworks
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_FEED: https://nuget.pkg.github.com/thecogworks
GITHUB_PACKAGES_OUTPUT: ${{ github.workspace }}/github_packages

steps:
- name: Checkout commit
- name: Checkout master
uses: actions/checkout@v2
with:
ref: master
Expand All @@ -47,44 +30,17 @@ jobs:
tag_check=$(git describe --exact-match `git rev-parse HEAD` | head -1)
echo "VERSION=$tag_check" >> $GITHUB_ENV
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: ${{ env.DOTNET_VERSION }}

- uses: nuget/setup-nuget@v1
- name: Download a single artifact
uses: actions/download-artifact@v2
with:
nuget-version: ${{ env.NUGET_VERSION }}

- name: NuGet Restore
run: nuget restore ${{ env.SOLUTION }}

- name: Install dependencies
run: dotnet restore ${{env.SOLUTION}}

- name: Build
run: |
dotnet build `
--configuration ${{ env.CONFIG }} `
${{ env.SOLUTION }}
- name: Pack all nuspec files
shell: bash
working-directory: ${{ github.workspace }}
run: |
for nuspecFile in ./Source/**/*.nuspec
do
nuget pack $nuspecFile \
-Version ${{ env.VERSION }} \
-Properties Configuration=${{ env.CONFIG }} \
-OutputDirectory .\${{ env.NUGET_OUTPUT }}
done
name: build_${{ env.PROJECT_NAME }}.${{ env.VERSION }}
path: ${{ env.GITHUB_PACKAGES_OUTPUT }}

- name: Push to GitHub Feed
shell: bash
working-directory: ${{ github.workspace }}
working-directory: ${{ env.GITHUB_PACKAGES_OUTPUT }}
run: |
for nugetFile in ./.${{ env.NUGET_OUTPUT }}/*.nupkg
for nugetFile in ./*.nupkg
do
curl -vX PUT -u "$GITHUB_USER:$GITHUB_TOKEN" -F package=@$nugetFile $GITHUB_FEED
done
58 changes: 12 additions & 46 deletions .github/workflows/release-myget.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,40 +2,28 @@ name: (NuGet) MyGet Release

on:
workflow_run:
workflows: [ "Changelog generator" ]
workflows: [ "Build" ]
types:
- completed
jobs:
myget_release:
name: MyGet Release
if: ${{ github.event.workflow_run.conclusion == 'success' }}
if: ${{ github.event.workflow_run.conclusion == 'success' && github.event_name != 'pull_request' }}
runs-on: windows-latest
env:
# Dotnet Setup
DOTNET_VERSION: 3.1.401

# Stop wasting time caching packages
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true

# Disable sending usage data to Microsoft
DOTNET_CLI_TELEMETRY_OPTOUT: true

# Nuget Setup
NUGET_VERSION: 'latest'
NUGET_OUTPUT: output
NUGET_OUTPUT: ${{ github.workspace }}/my_get

# Solution Setup
CONFIG: 'Release'
SOLUTION: 'Source\Cogworks.Essentials.sln'
VERSION: '1.0.0'

# MyGet Feed settings
MYGET_USER: thecogworks
MYGET_TOKEN: ${{ secrets.MYGET_TOKEN }}
MYGET_FEED: https://www.myget.org/F/cogworks-packages/auth/${{ secrets.MYGET_TOKEN }}/api/v3/index.json

steps:
- name: Checkout commit
- name: Checkout master
uses: actions/checkout@v2
with:
ref: master
Expand All @@ -47,44 +35,22 @@ jobs:
tag_check=$(git describe --exact-match `git rev-parse HEAD` | head -1)
echo "VERSION=$tag_check" >> $GITHUB_ENV
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
- name: Download a single artifact
uses: actions/download-artifact@v2
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
name: build_${{ env.PROJECT_NAME }}.${{ env.VERSION }}
path: ${{ env.NUGET_OUTPUT }}

- uses: nuget/setup-nuget@v1
- name: Configure NuGet
uses: nuget/setup-nuget@v1
with:
nuget-version: ${{ env.NUGET_VERSION }}

- name: NuGet Restore
run: nuget restore ${{ env.SOLUTION }}

- name: Install dependencies
run: dotnet restore ${{env.SOLUTION}}

- name: Build
run: |
dotnet build `
--configuration ${{ env.CONFIG }} `
${{ env.SOLUTION }}
- name: Pack all nuspec files
shell: bash
working-directory: ${{ github.workspace }}
run: |
for nuspecFile in ./Source/**/*.nuspec
do
nuget pack $nuspecFile \
-Version ${{ env.VERSION }} \
-Properties Configuration=${{ env.CONFIG }} \
-OutputDirectory .\${{ env.NUGET_OUTPUT }}
done
- name: Push to MyGet Feed
shell: bash
working-directory: ${{ github.workspace }}
working-directory: ${{ env.NUGET_OUTPUT }}
run: |
for nugetFile in ./.${{ env.NUGET_OUTPUT }}/*.nupkg
for nugetFile in ./*.nupkg
do
nuget push $nugetFile ${{ env.MYGET_TOKEN }} -Source ${{ env.MYGET_FEED }}
done
62 changes: 24 additions & 38 deletions .github/workflows/release-umbraco.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,27 @@ name: (Umbraco) Our.Umbraco Package Generation

on:
workflow_run:
workflows: [ "Changelog generator" ]
workflows: [ "Build" ]
types:
- completed
jobs:
our_umbraco:
name: Our.Umbraco Package Generation
if: ${{ github.event.workflow_run.conclusion == 'success' }}
if: ${{ github.event.workflow_run.conclusion == 'success' && github.event_name != 'pull_request' }}
runs-on: windows-latest
env:
# Dotnet Setup
DOTNET_VERSION: 3.1.401

# Stop wasting time caching packages
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true

# Disable sending usage data to Microsoft
DOTNET_CLI_TELEMETRY_OPTOUT: true

# Nuget Setup
NUGET_VERSION: 'latest'
NUGET_OUTPUT: output
NUGET_OUTPUT: './.output/nuget/'
NUGET_EXTRACTED: './.output/nuget/extracted/'

# Solution Setup
CONFIG: 'Release'
SOLUTION: 'Source\Cogworks.Essentials.sln'
PACKAGE_NAME: 'Cogworks.Essentials'
# Project Setup
VERSION: '1.0.0'
UMBRACO_OUTPUT: '.output/umbraco'
PACKAGE_NAME: 'Cogworks.Essentials'
UMBRACO_OUTPUT: './.output/umbraco/'

steps:
- name: Checkout commit
- name: Checkout master
uses: actions/checkout@v2
with:
ref: master
Expand All @@ -44,43 +34,39 @@ jobs:
tag_check=$(git describe --exact-match `git rev-parse HEAD` | head -1)
echo "VERSION=$tag_check" >> $GITHUB_ENV
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: ${{ env.DOTNET_VERSION }}

- uses: nuget/setup-nuget@v1
- name: Configure NuGet
uses: nuget/setup-nuget@v1
with:
nuget-version: ${{ env.NUGET_VERSION }}

- name: NuGet Restore
run: nuget restore ${{ env.SOLUTION }}

- name: Install dependencies
run: dotnet restore ${{env.SOLUTION}}
- name: Download a single artifact
uses: actions/download-artifact@v2
with:
name: build_${{ env.PROJECT_NAME }}.${{ env.VERSION }}
path: ${{ env.NUGET_OUTPUT }}

- name: Build
- name: Extract artifact
shell: powershell
run: |
dotnet build `
--configuration ${{ env.CONFIG }} `
${{ env.SOLUTION }}
Install-Package -Name ${{ env.PACKAGE_NAME }} -Source ${{ env.NUGET_OUTPUT }} -Destination ${{ env.NUGET_EXTRACTED }}
- name: Copy package files
shell: bash
run: |
mkdir -p ./${{ env.UMBRACO_OUTPUT }}/ && find . -type d -regex ".*/${{ env.PACKAGE_NAME }}/bin/${{ env.CONFIG }}" -print0 | find $(xargs -0) -name "${{ env.PACKAGE_NAME }}*.dll" -print0 | xargs -0 -I {} cp -r {} ./${{ env.UMBRACO_OUTPUT }}/
mkdir -p ./${{ env.UMBRACO_OUTPUT }}/ && find . -type d -regex ".*/${{ env.PACKAGE_NAME }}/Web/UI" -print0 | xargs -0 -I {} cp -r {} ./${{ env.UMBRACO_OUTPUT }}/
mkdir -p ${{ env.UMBRACO_OUTPUT }} && find ${{ env.NUGET_EXTRACTED }} -name "*.dll" -print0 | xargs -0 -I {} cp -r {} ${{ env.UMBRACO_OUTPUT }}
mkdir -p ${{ env.UMBRACO_OUTPUT }} && find . -type d -regex ".*/${{ env.PACKAGE_NAME }}.${{ env.VERSION }}/.*App_Plugins" -print0 | xargs -0 -I {} cp -r {} ${{ env.UMBRACO_OUTPUT }}
is_empty_directory=$([ "$(ls -A ./${{ env.UMBRACO_OUTPUT }}/)" ] && echo false || echo true)
is_empty_directory=$([ "$(ls -A ${{ env.UMBRACO_OUTPUT }})" ] && echo false || echo true)
if [[ is_empty_directory == true ]]; then
echo "Empty output directory: ./${{ env.UMBRACO_OUTPUT }}/"
echo "Empty output directory: ${{ env.UMBRACO_OUTPUT }}"
exit 1
fi
- name: Upload Our.Umbraco package Artifact to GitHub Action
uses: actions/upload-artifact@v2
with:
name: ${{ env.PACKAGE_NAME }}.${{ env.VERSION }}
path: ./${{ env.UMBRACO_OUTPUT }}/
path: ${{ env.UMBRACO_OUTPUT }}

0 comments on commit 2f6ad3a

Please sign in to comment.