-
Notifications
You must be signed in to change notification settings - Fork 6
109 lines (100 loc) · 3.26 KB
/
ci.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
name: ci
on:
workflow_dispatch:
push:
branches:
- "**"
paths:
- ".github/workflows/ci.yml"
- "src/**"
- "*.sln"
- "*.props"
tags:
- "v*"
pull_request:
branches:
- "**"
paths:
- ".github/workflows/ci.yml"
- "src/**"
- "*.sln"
- "*.props"
jobs:
meta:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- id: meta
run: |
is_release=${{ startsWith(github.ref, 'refs/tags/v') }}
tag=$(git describe --tags --match "v*" ${{ github.ref }} || true)
if [[ $tag != v* ]]; then
tag=$(date "+v0.0.0-%y%m%d-$(git rev-parse --short HEAD)")
fi
if ! $($is_release) ; then
prefix=${tag%-*-*}
suffix=${tag#$prefix-}
next=${prefix##*.}
((++next))
prefix=${prefix%.*}
tag="$prefix.$next-Preview.$suffix"
fi
echo tag=$tag | tee -a $GITHUB_OUTPUT
echo version=${tag#v} | tee -a $GITHUB_OUTPUT
echo is_release=$is_release | tee -a $GITHUB_OUTPUT
outputs:
tag: ${{ steps.meta.outputs.tag }}
version: ${{ steps.meta.outputs.version }}
is_release: ${{ steps.meta.outputs.is_release }}
publish:
needs: [meta]
strategy:
fail-fast: false
matrix:
project: [MBA.Cli]
os: [win, linux, osx]
arch: [x64, arm64]
suffix: [-single-cut]
dotnet: ['7.0']
include:
- project: MBA.Cli
os: win
arch: x64
suffix: -single-runtime-relied
dotnet: '7.0'
env:
NUGET_PACKAGES: ${{ github.workspace }}/.nuget/packages
PUBLISH_NAME: ${{ matrix.project }}-${{ matrix.os }}-${{ matrix.arch }}${{ matrix.suffix }}-${{ needs.meta.outputs.tag }}
PUBLISH_PATH: ./Publish #./Publish/${{ matrix.project }}-${{ matrix.os }}-${{ matrix.arch }}${{ matrix.suffix }}/
CSPROJ_PATH: ./src/${{ matrix.project }}/${{ matrix.project }}.csproj
PUBXML_PATH: ./src/${{ matrix.project }}/Properties/PublishProfiles/${{ matrix.os }}-${{ matrix.arch }}${{ matrix.suffix }}.pubxml
runs-on: windows-latest
steps:
- uses: actions/checkout@v3
with:
submodules: true
- uses: actions/setup-dotnet@v3
with:
dotnet-version: ${{ matrix.dotnet }}
cache: true
cache-dependency-path: '**/packages.lock.json'
- run: dotnet restore --locked-mode
- run: dotnet publish ${{ env.CSPROJ_PATH }} --no-restore -p:Version=${{ needs.meta.outputs.version }} -p:PublishProfile=${{ env.PUBXML_PATH }}
- uses: actions/upload-artifact@v3
if: always()
with:
name: ${{ env.PUBLISH_NAME }}
path: ${{ env.PUBLISH_PATH }}
- name: Pack
if: ${{ needs.meta.outputs.is_release == 'true' }}
working-directory: ${{ env.PUBLISH_PATH }}
run: 7z a -r ../${{ env.PUBLISH_NAME }}.zip ./*
- uses: softprops/action-gh-release@v1
if: ${{ needs.meta.outputs.is_release == 'true' }}
with:
body_path: CHANGELOG.md
prerelease: true
files: ${{ env.PUBLISH_NAME }}.zip
tag_name: ${{ needs.meta.outputs.tag }}