Skip to content

Commit 5680a3b

Browse files
authored
Fix/release package workflow (#14)
1 parent 46cad90 commit 5680a3b

File tree

6 files changed

+52
-24
lines changed

6 files changed

+52
-24
lines changed

.github/workflows/dotnet-ci.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,6 @@ jobs:
2222
update_version:
2323
name: Update Version
2424
needs: build_and_test
25+
uses: ./.github/workflows/wf-update-version.yaml
2526
permissions:
2627
contents: write
27-
uses: ./.github/workflows/wf-update-version.yaml

.github/workflows/dotnet-merge-develop.yaml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ name: .NET CI
22
run-name: Continuous Integration
33

44
on:
5-
pull_request_target:
6-
branches: ["develop"]
7-
types: [closed]
5+
pull_request_target:
6+
branches: ["develop"]
7+
types: [closed]
88

99
concurrency:
1010
group: ci-${{ github.workflow }}-${{ github.actor_id }}
@@ -18,8 +18,10 @@ jobs:
1818
update_version:
1919
name: Update Version
2020
needs: build_and_test
21+
uses: ./.github/workflows/wf-update-version.yaml
2122
permissions:
2223
contents: write
23-
uses: ./.github/workflows/wf-update-version.yaml
2424
with:
25-
bumpVersion: 0.^.0
25+
bumpVersion: 0.^.0
26+
userName: ${{ github.event.pull_request.user.login }}
27+
userEmail: ${{ github.event.pull_request.user.email }}

.github/workflows/dotnet-prerelease-pack.yaml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
name: .Nuget Pre-release
2-
run-name: Create pre-release NuGet packages
1+
name: Package Pre-Release
2+
run-name: Pack & Publish pre-release NuGet packages
33

44
on:
55
workflow_dispatch:
66
inputs:
7-
push_package:
7+
push_package_to_nuget:
88
description: 'Push package to NuGet.org'
99
type: boolean
1010
default: false
@@ -48,8 +48,10 @@ jobs:
4848
needs: [build_and_test, setup_env]
4949
name: Publish NuGet packages
5050
uses: ./.github/workflows/wf-publish-nuget.yaml
51+
permissions:
52+
packages: write
5153
with:
52-
push_package: ${{ github.event.inputs.push_package }}
54+
push_package_to_nuget: ${{ github.event.inputs.push_package_to_nuget == 'true' }}
5355
version_suffix: ${{ needs.setup_env.outputs.version_suffix }}
5456
secrets:
5557
nuget_api_key: ${{ secrets.NUGET_API_KEY_TEST }}

.github/workflows/dotnet-release.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: .NET Release
1+
name: Package Release
22
run-name: Release ${{ github.ref_name }}
33

44
on:
@@ -14,7 +14,7 @@ jobs:
1414
if: github.event.release.draft == false
1515
uses: ./.github/workflows/wf-publish-nuget.yaml
1616
with:
17-
push_package: ${{ github.event.release.prerelease == false }}
17+
push_package_to_nuget: ${{ github.event.release.prerelease == false }}
1818
secrets:
1919
nuget_api_key: ${{ secrets.NUGET_API_KEY_TEST }}
2020

.github/workflows/wf-publish-nuget.yaml

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ run-name: Publish NuGet Package
44
on:
55
workflow_call:
66
inputs:
7-
push_package:
7+
push_package_to_nuget:
88
type: boolean
99
default: false
1010
build_configuration:
@@ -21,10 +21,12 @@ on:
2121
required: true
2222

2323
env:
24-
PACKAGE_PATH: nupkgs
24+
PACKAGE_DIR_NAME: nupkgs
25+
PACKAGE_OUTPUT_PATH: ${{ github.workspace }}/nupkgs
26+
GITHUB_PACKAGE_SOURCE: "https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json"
2527

2628
jobs:
27-
prepare-package:
29+
prepare_package:
2830
name: Prepare Package
2931
runs-on: ubuntu-latest
3032

@@ -38,31 +40,45 @@ jobs:
3840
run: mkdir -p packages
3941

4042
- name: Pack
41-
run: dotnet pack $GITHUB_WORKSPACE/src/InvvardDev.Ifttt.csproj --output $PACKAGE_PATH --configuration ${{ inputs.build_configuration }} -p:GeneratePackageOnBuild=false
43+
run: dotnet pack $GITHUB_WORKSPACE/src/InvvardDev.Ifttt.csproj --version-suffix '${{ inputs.version_suffix }}' --output $PACKAGE_DIR_NAME --configuration ${{ inputs.build_configuration }} -p:GeneratePackageOnBuild=false
4244

4345
- name: Upload Artifact
4446
uses: actions/upload-artifact@v4
4547
with:
4648
name: nuget-packages
47-
path: $PACKAGE_PATH
49+
path: ${{ env.PACKAGE_OUTPUT_PATH }}
4850

49-
publish-to-nuget:
51+
publish_to_nuget:
5052
name: Publish Package to NuGet
53+
if: inputs.push_package_to_nuget
5154
runs-on: ubuntu-latest
55+
needs: [prepare_package]
5256

5357
steps:
58+
- name: Download Artifact
59+
uses: actions/download-artifact@v4
60+
with:
61+
name: nuget-packages
62+
path: ${{ env.PACKAGE_OUTPUT_PATH }}
63+
5464
- name: Publish to NuGet
55-
if: inputs.push_package
56-
run: dotnet nuget push $PACKAGE_PATH/*.* --api-key $api_key --source https://api.nuget.org/v3/index.json --skip-duplicate
65+
run: dotnet nuget push ${{ env.PACKAGE_OUTPUT_PATH }}/*.* --api-key $api_key --source https://api.nuget.org/v3/index.json --skip-duplicate
5766
env:
5867
api_key: ${{ secrets.nuget_api_key }}
5968

60-
publish-to-github:
69+
publish_to_github:
6170
name: Publish Package to GitHub Packages
6271
runs-on: ubuntu-latest
72+
needs: [prepare_package]
6373

6474
steps:
75+
- name: Download Artifact
76+
uses: actions/download-artifact@v4
77+
with:
78+
name: nuget-packages
79+
path: ${{ env.PACKAGE_OUTPUT_PATH }}
80+
6581
- name: Publish to GitHub Packages
66-
run: dotnet nuget push ${{ env.package_path }}/*.* --api-key $api_key --source https://nuget.pkg.github.com/InvvardDev/index.json --skip-duplicate --no-symbols
82+
run: dotnet nuget push ${{ env.PACKAGE_OUTPUT_PATH }}/*.* --api-key ${{ env.api_key }} --source ${{ env.GITHUB_PACKAGE_SOURCE }} --skip-duplicate --no-symbols
6783
env:
6884
api_key: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/wf-update-version.yaml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,14 @@ on:
88
description: "The version to bump to"
99
type: string
1010
default: bump-build
11+
userName:
12+
description: "The user name to use for the commit"
13+
type: string
14+
default: ${{ github.event.pusher.name }}
15+
userEmail:
16+
description: "The user email to use for the commit"
17+
type: string
18+
default: ${{ github.event.pusher.email }}
1119

1220
jobs:
1321
update_version:
@@ -38,8 +46,8 @@ jobs:
3846

3947
- name: Push new VersionPrefix
4048
run: |
41-
git config user.name "${{github.event.pusher.name}}"
42-
git config user.email "${{github.event.pusher.email}}"
49+
git config user.name "${{inputs.userName}}"
50+
git config user.email "${{inputs.userEmail}}"
4351
git add .
4452
git commit -m "Update Version Prefix from ${{ steps.bump_version_prefix.outputs.oldVersion }} to ${{ steps.bump_version_prefix.outputs.newVersion }}"
4553
git push

0 commit comments

Comments
 (0)