📦 Publish #9
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
name: '📦 Publish' | |
on: | |
workflow_dispatch: | |
branches: | |
- main | |
inputs: | |
bump: | |
description: "Version Bump Method" | |
type: choice | |
options: | |
- major | |
- minor | |
- patch | |
required: true | |
default: minor | |
workflow_call: | |
secrets: | |
NUGET_API_KEY: | |
description: "NuGet API Key" | |
required: true | |
inputs: | |
bump: | |
description: "Version Bump Method" | |
type: string | |
required: true | |
jobs: | |
publish: | |
name: 📦 Publish | |
runs-on: ubuntu-latest | |
steps: | |
- name: 🧾 Checkout | |
uses: actions/checkout@v3 | |
with: | |
lfs: true | |
submodules: 'recursive' | |
- name: 🔎 Read Current Project Verson | |
uses: KageKirin/get-csproj-version@v1.0.0 | |
id: current-version | |
with: | |
file: Chickensoft.AutoInject/Chickensoft.AutoInject.csproj | |
xpath: /Project/PropertyGroup/Version | |
- name: 🖨 Print Current Version | |
run: | | |
echo "Current Version: ${{ steps.current-version.outputs.version }}" | |
- name: 🧮 Compute Next Version | |
uses: chickensoft-games/next-godot-csproj-version@v1 | |
id: next-version | |
with: | |
project-version: ${{ steps.current-version.outputs.version }} | |
godot-version: global.json | |
bump: ${{ inputs.bump }} | |
- name: ✨ Print Next Version | |
run: | | |
echo "Next Version: ${{ steps.next-version.outputs.version }}" | |
- name: 📝 Change Version | |
uses: vers-one/dotnet-project-version-updater@v1.3 | |
with: | |
file: "Chickensoft.AutoInject/Chickensoft.AutoInject.csproj" | |
version: ${{ steps.next-version.outputs.version }} | |
- name: ✍️ Commit Changes | |
run: | | |
git config user.name "action@github.com" | |
git config user.email "GitHub Action" | |
git commit -a -m "chore(version): update version to ${{ steps.next-version.outputs.version }}" | |
git push | |
- name: 🖨 Copy Source to Source-Only package | |
run: | | |
# Copy source files from Chickensoft.AutoInject.Tests/src/**/*.cs | |
# to Chickensoft.AutoInject/src/**/*.cs | |
# | |
# Because source-only packages are hard to develop and test, we | |
# actually keep the source that goes in the source-only package inside | |
# the test project to make it easier to develop and test. | |
# | |
# we can always copy it right before publishing the package. | |
mkdir -p Chickensoft.AutoInject/src | |
cp -v -r Chickensoft.AutoInject.Tests/src/* Chickensoft.AutoInject/src/ | |
- name: ✨ Create Release | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: gh release create --generate-notes "v${{ steps.next-version.outputs.version }}" | |
- name: 💽 Setup .NET SDK | |
uses: actions/setup-dotnet@v3 | |
with: | |
# Use the .NET SDK from global.json in the root of the repository. | |
global-json-file: global.json | |
- name: 🛠 Build Source-Only Package | |
working-directory: Chickensoft.AutoInject | |
run: | | |
dotnet build -c Release | |
- name: 📦 Publish | |
run: | | |
# find the built nuget package | |
nuget_package=$(find ./nupkg -name "Chickensoft.AutoInject.*.nupkg") | |
echo "📦 Publishing package: $nuget_package" | |
# publish the nuget package | |
dotnet nuget push "$nuget_package" --api-key "${{ secrets.NUGET_API_KEY }}" --source "https://api.nuget.org/v3/index.json" --skip-duplicate |