-
Notifications
You must be signed in to change notification settings - Fork 0
105 lines (86 loc) · 2.99 KB
/
publish.yml
File metadata and controls
105 lines (86 loc) · 2.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
name: Publish NuGet Package
on:
release:
types:
- published
workflow_dispatch:
permissions:
contents: write
packages: write
jobs:
publish:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 10.0.x
- name: Resolve package version
id: version
shell: bash
run: |
if [[ "${{ github.event_name }}" == "release" ]]; then
TAG_NAME="${{ github.event.release.tag_name }}"
elif [[ "${{ github.ref_type }}" == "tag" ]]; then
TAG_NAME="${{ github.ref_name }}"
else
echo "workflow_dispatch must be run from a tag ref such as v1.0.4." >&2
exit 1
fi
PACKAGE_VERSION="${TAG_NAME#v}"
if [[ -z "${PACKAGE_VERSION}" ]]; then
echo "Package version could not be resolved from the release tag." >&2
exit 1
fi
echo "tag_name=${TAG_NAME}" >> "${GITHUB_OUTPUT}"
echo "package_version=${PACKAGE_VERSION}" >> "${GITHUB_OUTPUT}"
- name: Restore
run: dotnet restore YCode.CLI/YCode.CLI.csproj
- name: Pack
run: >
dotnet pack YCode.CLI/YCode.CLI.csproj
--configuration Release
--no-restore
-p:ContinuousIntegrationBuild=true
-p:PackageVersion=${{ steps.version.outputs.package_version }}
--output ${{ github.workspace }}/artifacts
- name: Publish to NuGet.org
shell: bash
run: |
shopt -s nullglob
packages=("${{ github.workspace }}/artifacts/"*.nupkg)
if (( ${#packages[@]} == 0 )); then
echo "No .nupkg files were generated." >&2
exit 1
fi
dotnet nuget push "${packages[@]}" \
--api-key "${{ secrets.NUGET_API_KEY }}" \
--source "https://api.nuget.org/v3/index.json" \
--skip-duplicate
- name: Configure GitHub Packages source
run: >
dotnet nuget add source
--username "${{ github.repository_owner }}"
--password "${{ secrets.GITHUB_TOKEN }}"
--store-password-in-clear-text
--name github
"https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json"
- name: Publish to GitHub Packages
shell: bash
run: |
shopt -s nullglob
packages=("${{ github.workspace }}/artifacts/"*.nupkg)
dotnet nuget push "${packages[@]}" \
--source github \
--api-key "${{ secrets.GITHUB_TOKEN }}" \
--skip-duplicate
- name: Upload package to GitHub Release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
shell: bash
run: |
shopt -s nullglob
packages=("${{ github.workspace }}/artifacts/"*.nupkg)
gh release upload "${{ steps.version.outputs.tag_name }}" "${packages[@]}" --clobber