Skip to content

Commit

Permalink
Change workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
Mbucari committed Jun 9, 2023
1 parent 5ed4428 commit 0ccaca2
Show file tree
Hide file tree
Showing 3 changed files with 101 additions and 53 deletions.
78 changes: 78 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# build-windows.yml
# Reusable workflow that builds the Windows versions of Libation.
---
name: build

on:
workflow_call:
inputs:
version_override:
type: string
description: 'Version number override'
required: false
project_file:
type: string
description: 'Path to the .csproj file'
required: true
nuspec_file:
type: string
description: 'Path to the .nuspec file'
required: true
secrets:
nuget_token:
description: 'Nuget Api authentication token'
required: false

env:
DOTNET_CONFIGURATION: 'Release'
DOTNET_VERSION: '6.0.x'
NUGET_SOURCE: 'https://api.nuget.org/v3/index.json'

jobs:
build:
name: Build and Publish
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
env:
NUGET_AUTH_TOKEN: ${{ secrets.nuget_token }}

- name: Get version
id: get_version
working-directory:
run: |
inputVersion="${{ inputs.version_override }}"
if [[ "${#inputVersion}" -gt 0 ]]
then
version="${inputVersion}"
else
version="$(grep -Eio -m 1 '<Version>.*</Version>' ${{ inputs.project_file }} | sed -r 's/<\/?Version>//g')"
fi
echo "version=${version}" >> "${GITHUB_OUTPUT}"
- name: Build and Pack
id: build_pack
run: |
nuspec_relative=$(realpath --relative-to="$(dirname ${{ inputs.project_file }})" "${{ inputs.nuspec_file }}")
dotnet build ${{ inputs.project_file }} -c ${{ env.DOTNET_CONFIGURATION }}
dotnet pack ${{ inputs.project_file }} --no-build -c ${{ env.DOTNET_CONFIGURATION }} -o . -p:NuspecFile="$nuspec_relative" -p:NuspecProperties="version=${{ steps.get_version.outputs.version }}"
nupkg=$(ls *.nupkg)
echo "nupkg=${nupkg}" >> "${GITHUB_OUTPUT}"
- name: Upload Artifact
uses: actions/upload-artifact@v3
with:
name: '${{ steps.build_pack.outputs.nupkg }}'
path: ./
if-no-files-found: error
retention-days: 7

- name: Publish nupkg
continue-on-error : true
run: |
dotnet nuget push '${{ steps.build_pack.outputs.nupkg }}' -s ${{ env.NUGET_SOURCE }} -k ${{ secrets.nuget_token }} --skip-duplicate
66 changes: 16 additions & 50 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,53 +1,19 @@
name: publish to nuget
# validate.yml
# Validates that Libation will build on a pull request or push to master.
---
name: validate

on:
push:
branches:
- master # Default release branch
jobs:
publish:
name: build, pack & publish
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Setup dotnet
uses: actions/setup-dotnet@v1
with:
dotnet-version: 6.0.x
# Publish
- name: publish on version change
id: publish_nuget
uses: Mbucari/publish-nuget@master
with:
# Filepath of the project to be packaged, relative to root of repository
PROJECT_FILE_PATH: src/AAXClean/AAXClean.csproj

# NuGet package id, used for version detection & defaults to project name
PACKAGE_NAME: AAXClean

BUILD_PLATFORM: AnyCPU
BUILD_CONFIGURATION: Release
NUSPEC_FILE: ../../AAXClean.nuspec

# Filepath with version info, relative to root of repository & defaults to PROJECT_FILE_PATH
# VERSION_FILE_PATH: Directory.Build.props

# Regex pattern to extract version info in a capturing group
VERSION_REGEX: ^\s*<Version>(.*)<\/Version>\s*$

# Useful with external providers like Nerdbank.GitVersioning, ignores VERSION_FILE_PATH & VERSION_REGEX
# VERSION_STATIC: 1.0.0

# Flag to toggle git tagging, enabled by default
# TAG_COMMIT: true
branches: [master]
pull_request:
branches: [master]

# Format of the git tag, [*] gets replaced with actual version
# TAG_FORMAT: v*

# API key to authenticate with NuGet server
NUGET_KEY: ${{secrets.AAXClean_NUGET_API_KEY}}

# NuGet server uri hosting the packages, defaults to https://api.nuget.org
# NUGET_SOURCE: https://api.nuget.org

# Flag to toggle pushing symbols along with nuget package to the server, disabled by default
INCLUDE_SYMBOLS: false
jobs:
build:
uses: ./.github/workflows/build.yml
with:
project_file: ./src/AAXClean/AAXClean.csproj
nuspec_file: ./AAXClean.nuspec
secrets:
nuget_token: ${{ secrets.AAXCLEAN_NUGET_API_KEY }}
10 changes: 7 additions & 3 deletions AAXClean.nuspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<metadata>
<id>AAXClean</id>
<version>1.0.3</version>
<version>0.0.0</version>
<description>Decrypts Audible aax and aaxc files to mp4.</description>
<authors>MrGneissGuy</authors>
<repository type="git" url="https://github.com/Mbucari/AAXClean.git" branch="master" />
Expand All @@ -10,7 +10,10 @@
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<Tags>Audible AAC AAXC m4b audiobook</Tags>
<language>en-US</language>
<releaseNotes>* Exposed Apple List Box to add custom tags</releaseNotes>
<readme>docs\README.md</readme>
<dependencies>
<group targetFramework="net6.0" />
</dependencies>
</metadata>
<dependencies>
<group targetFramework="net6.0">
Expand All @@ -19,6 +22,7 @@
</dependencies>
<files>
<file src="src\AAXClean\bin\Release\net6.0\AAXClean.dll" target="lib\net6.0\AAXClean.dll" />
<file src="src\AAXClean\bin\Release\net6.0\Mpeg4Lib.dll" target="lib\net6.0\Mpeg4Lib.dll" />
<file src="src\AAXClean\bin\Release\net6.0\Mpeg4Lib.dll" target="lib\net6.0\Mpeg4Lib.dll" />
<file src="README.md" target="docs\" />
</files>
</Project>

0 comments on commit 0ccaca2

Please sign in to comment.