-
-
Notifications
You must be signed in to change notification settings - Fork 1
81 lines (69 loc) · 2.61 KB
/
pack.yaml
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
name: Build and Publish NuGet Package
on:
release:
types: [published]
jobs:
build-and-publish:
runs-on: ubuntu-latest
permissions:
contents: write
packages: write
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PROJECTS: |
Source/Silverfly/Silverfly.csproj
Source/Silverfly.Testing/Silverfly.Testing.csproj
Source/Silverfly.Generator/Silverfly.Generator.csproj
Source/Silverfly.Repl/Silverfly.Repl.csproj
Source/Silverfly.TreeVisualizer/Silverfly.TreeVisualizer.csproj
Source/Silverfly.Backend/Silverfly.Backend.csproj
Source/Samples/Sample.FuncLanguage/Sample.FuncLanguage.csproj
steps:
- name: Checkout code
uses: actions/[email protected]
with:
fetch-depth: 0
ref: main
- name: Set default branch.
run: |
git fetch origin
git remote set-head origin --auto
- name: Prepare repository
run: git checkout main
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: '8.x'
- name: Get release version
id: get_release
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
- name: Update .csproj files
run: |
RELEASE_VERSION=${{ env.RELEASE_VERSION }}
IFS=$'\n' # Set the Internal Field Separator to newline for reading multi-line variable
for PROJECT in $PROJECTS; do
sed -i "s/<Version>.*<\/Version>/<Version>${RELEASE_VERSION}<\/Version>/" "$PROJECT"
done
- name: GIT commit and push overriding conflicts with local changes (verbose)
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git add Source/*.csproj
git commit -m "Update version to ${{ env.RELEASE_VERSION }}"
git fetch origin
git rebase --strategy-option=theirs origin/main
git push
- name: Build and package
run: |
IFS=$'\n' # Set the Internal Field Separator to newline for reading multi-line variable
for PROJECT in $PROJECTS; do
dotnet build -c Release -o ./nuget "$PROJECT"
done
- name: Publish to NuGet
uses: actions/upload-artifact@v4
with:
name: nuget-package
path: ./nuget/*.nupkg
- name: Publish package To Nuget
run: |
dotnet nuget push ./nuget/*.nupkg --api-key "${{ secrets.NUGET_APIKEY }}" --source https://api.nuget.org/v3/index.json --skip-duplicate