-
Notifications
You must be signed in to change notification settings - Fork 4
95 lines (87 loc) · 3.37 KB
/
release.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
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
name: Release
env:
solution_file: 'src/Vipps.net.sln'
on:
push:
branches: [ "main" ]
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: write # needed to push tag
strategy:
matrix:
dotnet-version: [ '8.0.x' ]
steps:
- name: Get repo with depth
uses: actions/checkout@v3
with:
fetch-depth: 0 # needed to calculate version
- name: Setup .NET Core SDK ${{ matrix.dotnet-version }}
uses: actions/setup-dotnet@v3
with:
dotnet-version: ${{ matrix.dotnet-version }}
- name: Install Paket
run: dotnet tool install Paket --tool-path .paket
working-directory: ./src
- name: Install dependencies
run: |
.paket/paket install
working-directory: ./src
- name: Build project
run: |
dotnet build "./src/Vipps.net.Models.Checkout" --configuration Release
dotnet build "./src/Vipps.net.Models.Epayment" --configuration Release
dotnet build "./src/Vipps.net" --configuration Release
- name: Pack NuGet Package with Paket
run: |
.paket/paket pack Vipps.net
working-directory: ./src
# Setup necessary info to create tag
- name: Set tag variable with v, for use in tag and release based on packed NuGet
run: |
RELEASE_VERSION=$(find ./src/Vipps.net -maxdepth 1 -name 'Vipps.net.*.nupkg' \
| head -n 1 \
| xargs -n 1 basename \
| grep -oP '(\d+\.\d+\.\d+(.*?))')
echo "RELEASE_VERSION=${RELEASE_VERSION}" >> $GITHUB_ENV
echo "RELEASE_TAG=v${RELEASE_VERSION}" >> $GITHUB_ENV
- name: Configure git username
run: git config user.name github-actions-bot
- name: Configure git user email
run: git config user.email noreply@vipps.no
# Create git tag
- name: Create Tag
run: git tag v${{ env.RELEASE_TAG }} -m ${{ env.RELEASE_TAG }}
- name: Publish Tag
run: git push --tags
# Create git release
- name: "Create GitHub Release"
uses: "actions/github-script@v6"
with:
github-token: "${{ secrets.GITHUB_TOKEN }}"
script: |
try {
const response = await github.rest.repos.createRelease({
draft: false,
generate_release_notes: true,
name: process.env.RELEASE_TAG,
owner: context.repo.owner,
prerelease: false,
repo: context.repo.repo,
tag_name: process.env.RELEASE_TAG,
});
core.exportVariable('RELEASE_ID', response.data.id);
core.exportVariable('RELEASE_UPLOAD_URL', response.data.upload_url);
} catch (error) {
core.setFailed(error.message);
}
- name: Upload to GitHub release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAG: ${{ env.RELEASE_TAG }}
run: |
gh release upload ${{ env.RELEASE_TAG }} src/Vipps.net/Vipps.net.${{ env.RELEASE_VERSION }}.nupkg --clobber
# Publish Nuget package
- name: Publish Nuget package
run: dotnet nuget push src/Vipps.net/Vipps.net.${{ env.RELEASE_VERSION }}.nupkg --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json