forked from loic-sharma/BaGet
-
Notifications
You must be signed in to change notification settings - Fork 56
110 lines (104 loc) · 3.78 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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
name: Release
on:
push:
tags:
- 'v*.*.*'
jobs:
version:
runs-on: ubuntu-latest
steps:
- id: get-version-tag
run: |
export GITHUB_REF_NAME="${{ github.ref_name }}"
export RELEASE_VERSION="${GITHUB_REF_NAME#v}"
echo "RELEASE_VERSION=$RELEASE_VERSION" >> $GITHUB_OUTPUT
outputs:
RELEASE_VERSION: ${{ steps.get-version-tag.outputs.RELEASE_VERSION }}
verify:
name: Run tests
runs-on: ubuntu-latest
needs: version
steps:
- uses: actions/checkout@v4.1.1
- name: Setup .NET
uses: actions/setup-dotnet@v4.0.0
with:
global-json-file: global.json
- name: Test
run: dotnet test --verbosity normal
release_zip:
if: ${{ github.ref_type == 'tag' }}
needs: [version, verify]
name: Release BaGetter.zip to GitHub
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4.1.1
with:
fetch-depth: 0
- name: Setup .NET
uses: actions/setup-dotnet@v4.0.0
with:
global-json-file: global.json
- name: Publish
run: |
dotnet publish src/BaGetter --configuration Release --output artifacts --property:Version=${{ needs.version.outputs.RELEASE_VERSION }}
echo ${{ github.sha }} > artifacts/ReleaseSha.txt
7z a -tzip bagetter-${{ needs.version.outputs.RELEASE_VERSION }}.zip ./artifacts/*
- name: Generate changelog with git-cliff
uses: tj-actions/git-cliff@v1.4.2
with:
args: --latest --strip all
output: "CHANGELOG.md"
- name: Create release with ncipollo/release-action
uses: ncipollo/release-action@v1.14.0
with:
bodyFile: "CHANGELOG.md"
artifacts: "bagetter-${{ needs.version.outputs.RELEASE_VERSION }}.zip"
name: ${{ needs.version.outputs.RELEASE_VERSION }}
prerelease: ${{ contains(github.ref_name, '-') }}
release_packages:
if: ${{ github.ref_type == 'tag' }}
needs: [version, verify]
name: Release packages to nuget.org
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4.1.1
- name: Setup .NET
uses: actions/setup-dotnet@v4.0.0
with:
global-json-file: global.json
- name: Pack
run: |
export PackageVersion=${{ needs.version.outputs.RELEASE_VERSION }}
export PackageSource=${PackageSource:="https://api.nuget.org/v3/index.json"}
echo "PackageSource=${PackageSource}" >> $GITHUB_ENV
dotnet pack --configuration Release --output artifacts --property:Version=${{ needs.version.outputs.RELEASE_VERSION }}
- name: Push
run: dotnet nuget push "*" -s ${PackageSource} -k ${{secrets.NUGET_API_KEY}}
working-directory: artifacts
release_docker_image:
if: ${{ github.ref_type == 'tag' }}
needs: [version, verify]
name: Release Docker image to Docker Hub
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4.1.1
- name: Login to Docker Hub
uses: docker/login-action@v3.0.0
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Set release version
run: echo "PackageVersion=${{ needs.version.outputs.RELEASE_VERSION }}" >> $GITHUB_ENV
- name: Build and push Docker image
uses: docker/build-push-action@v5.1.0
with:
context: .
push: true
tags: |
bagetter/bagetter:latest
bagetter/bagetter:${{ needs.version.outputs.RELEASE_VERSION }}
build-args: |
Version=${{ needs.version.outputs.RELEASE_VERSION }}