-
Notifications
You must be signed in to change notification settings - Fork 11
64 lines (60 loc) · 2.51 KB
/
pr-actions.yml
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
name: PR actions
on:
issue_comment:
types: [created, edited]
jobs:
publish:
name: Publish PR packages
runs-on: ubuntu-latest
if: github.event.issue.pull_request && contains(github.event.comment.body, '/publish')
env:
DOTNET_HOSTBUILDER__RELOADCONFIGONCHANGE: false
steps:
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
8.0.x
- uses: actions/checkout@v4
with:
ref: ${{ format('refs/pull/{0}/head', github.event.issue.number) }}
fetch-depth: 0
- name: Build PR release version
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
dotnet tool restore
sha=$(gh pr view ${{ github.event.issue.number }} --repo ${{ github.repository }} --json headRefOid | jq -r '.headRefOid' | cut -c1-8)
branch=$(gh pr view ${{ github.event.issue.number }} --repo ${{ github.repository }} --json headRefName | jq -r '.headRefName' | sed 's/.*\///')
version=$(dotnet minver --tag-prefix v --ignore-height --default-pre-release-identifiers preview.0).$branch.$sha
echo "MINVERVERSIONOVERRIDE=$version" >> $GITHUB_ENV
echo $version
- name: Build
run: |
dotnet build AppLibDotnet.sln -v m -c Release
- name: Test
run: |
dotnet test AppLibDotnet.sln -v m --no-restore --no-build -c Release
- name: Pack PR release
run: |
dotnet pack AppLibDotnet.sln -v m --no-restore --no-build -c Release -p:Deterministic=true
- name: Versions
run: |
dotnet --version
- name: Publish PR release
run: |
dotnet nuget push src/**/bin/Release/*.nupkg --source https://api.nuget.org/v3/index.json --api-key ${{ secrets.NUGET_API_KEY }} --skip-duplicate
- uses: actions/github-script@v7
name: Comment on PR
with:
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: `
Published PR packages:
* [Altinn.App.Api ${process.env.MINVERVERSIONOVERRIDE}](https://www.nuget.org/packages/Altinn.App.Api.Experimental/${process.env.MINVERVERSIONOVERRIDE})
* [Altinn.App.Core ${process.env.MINVERVERSIONOVERRIDE}](https://www.nuget.org/packages/Altinn.App.Core.Experimental/${process.env.MINVERVERSIONOVERRIDE})
`
})