-
Notifications
You must be signed in to change notification settings - Fork 6
104 lines (93 loc) · 3.02 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
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
shell: bash
run: |
is_release=${{ startsWith(github.ref, 'refs/tags/v') }}
tag=$(git describe --tags --match "v*" ${{ github.ref }} || date "+v0.0.0-%y%m%d-$(git rev-parse --short HEAD)")
if ! $($is_release) ; then
prefix=${tag%-*-*}
suffix=${tag#$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:
matrix:
project: [MBA.Cli]
os: [win, linux, osx]
arch: [x64, arm64]
suffix: [-single-cut]
dotnet: [ '7.0' ]
fail-fast: false
env:
NUGET_PACKAGES: ${{ github.workspace }}/.nuget/packages
PUBLISH_NAME: ${{ matrix.project }}-${{ needs.meta.outputs.tag }}-${{ matrix.os }}-${{ matrix.arch }}${{ matrix.suffix }}
PUBLISH_PATH: ./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: ls ./src/MBA.Cli
- run: ls ./src/MBA.Cli/Properties
- run: ls ./src/MBA.Cli/Properties/PublishProfiles
- run: dotnet publish ${{ env.CSPROJ_PATH }} --no-restore -p:Version=${{ needs.meta.outputs.version }} -p:PublishProfile=${{ env.PUBXML_PATH }}
- name: Pack
shell: bash
run: |
cd ${{ env.PUBLISH_PATH }}
zip -r ../$f.zip ./*
- uses: actions/upload-artifact@v3
if: always()
with:
name: ${{ env.PUBLISH_NAME }}
path: ${{ env.PUBLISH_PATH }}
- uses: softprops/action-gh-release@v1
if: ${{ needs.meta.outputs.is_release == 'true' }}
with:
body_path: CHANGELOG.md
prerelease: true
files: Publish/*.zip
tag_name: ${{ needs.meta.outputs.tag }}