Skip to content

Commit 3f4d5cb

Browse files
committed
add CI/CD
1 parent 27d8325 commit 3f4d5cb

File tree

2 files changed

+117
-1
lines changed

2 files changed

+117
-1
lines changed

.github/workflows/release.yml

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
on:
2+
push:
3+
tags:
4+
- '[0-9]+.[0-9]+.[0-9]+'
5+
- '[0-9]+.[0-9]+.[0-9]+-alpha.[0-9]+'
6+
- '[0-9]+.[0-9]+.[0-9]+-beta.[0-9]+'
7+
- '[0-9]+.[0-9]+.[0-9]+-rc.[0-9]+'
8+
9+
name: release
10+
11+
env:
12+
PROJECT_DIR: ./Emb.Cli.NetCore
13+
PROJECT_PATH: ./Emb.Cli.NetCore/Emb.Cli.NetCore.csproj
14+
FRAMEWORK: net8.0
15+
SELF_CONTAINED: true
16+
FILE_PREFIX: ExtensibleMessageBroker_
17+
18+
jobs:
19+
build:
20+
name: Build and Package
21+
runs-on: ubuntu-latest
22+
23+
strategy:
24+
matrix:
25+
rid:
26+
- win-x64
27+
- win-arm64
28+
- linux-x64
29+
- linux-arm64
30+
- osx-arm64
31+
32+
steps:
33+
- name: Checkout
34+
uses: actions/checkout@v4
35+
with:
36+
fetch-depth: 0
37+
38+
- name: Install .NET
39+
uses: actions/setup-dotnet@v4
40+
with:
41+
dotnet-version: '8.0.x'
42+
43+
- name: Get branch and tag
44+
id: branch_name
45+
run: |
46+
echo "SOURCE_TAG=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
47+
48+
- name: Get ref info
49+
id: ref_info
50+
env:
51+
GIT_TAG: ${{ steps.branch_name.outputs.SOURCE_TAG }}
52+
run: |
53+
if [[ -z ${GIT_TAG} ]]; then exit 1; else appversion=${GIT_TAG}; fi
54+
echo "VERSION=${appversion}" >> $GITHUB_OUTPUT
55+
56+
- name: Replace project version
57+
run: |
58+
sed -i "s/<Version>.*<\/Version>/<Version>${{ steps.ref_info.outputs.VERSION }}<\/Version>/" ${{ env.PROJECT_PATH }}
59+
60+
- name: Build and package
61+
id: build_package
62+
working-directory: ${{ env.PROJECT_DIR }}
63+
shell: bash
64+
run: |
65+
if [ "${{ env.SELF_CONTAINED }}" = "true" ]; then
66+
SC_FLAG="--self-contained"
67+
SC_POSTFIX="_self-contained"
68+
else
69+
SC_FLAG="--no-self-contained"
70+
SC_POSTFIX=""
71+
fi
72+
73+
dotnet publish -c release -r ${{ matrix.rid }} --framework ${{ env.FRAMEWORK }} $SC_FLAG
74+
75+
ZIP_NAME="${{ env.FILE_PREFIX }}${{ matrix.rid }}_${{ env.FRAMEWORK }}${SC_POSTFIX}.zip"
76+
7z a "$ZIP_NAME" "./bin/release/${{ env.FRAMEWORK }}/${{ matrix.rid }}/publish/*"
77+
78+
# Set output variable for ZIP_NAME
79+
echo "ZIP_NAME=$ZIP_NAME" >> $GITHUB_OUTPUT
80+
81+
- name: Upload artifact
82+
uses: actions/upload-artifact@v4
83+
with:
84+
name: ${{ steps.build_package.outputs.ZIP_NAME }}
85+
path: ${{ env.PROJECT_DIR }}/${{ steps.build_package.outputs.ZIP_NAME }}
86+
87+
publish:
88+
name: Publish Release
89+
runs-on: ubuntu-latest
90+
needs: build
91+
steps:
92+
- name: Download artifacts
93+
uses: actions/download-artifact@v4
94+
with:
95+
path: ./artifacts
96+
97+
- name: Get ref info
98+
id: ref_info
99+
run: |
100+
GIT_TAG=${GITHUB_REF#refs/tags/}
101+
if [[ ${GIT_TAG} =~ (alpha|beta|rc) ]]; then
102+
echo "IS_PRERELEASE=true" >> $GITHUB_OUTPUT
103+
echo "MAKE_LATEST=false" >> $GITHUB_OUTPUT
104+
else
105+
echo "IS_PRERELEASE=false" >> $GITHUB_OUTPUT
106+
echo "MAKE_LATEST=true" >> $GITHUB_OUTPUT
107+
fi
108+
109+
- name: Publish Release
110+
uses: softprops/action-gh-release@v2
111+
if: startsWith(github.ref, 'refs/tags/')
112+
with:
113+
prerelease: ${{ steps.ref_info.outputs.IS_PRERELEASE }}
114+
make_latest: ${{ steps.ref_info.outputs.MAKE_LATEST }}
115+
generate_release_notes: true
116+
files: ./artifacts/**/*.zip

Directory.Packages.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,6 @@
3737
<PackageVersion Include="System.Runtime.Loader" Version="4.3.0" />
3838
<PackageVersion Include="System.Security.Cryptography.Primitives" Version="4.3.0" />
3939
<PackageVersion Include="System.Text.Encoding.Extensions" Version="4.3.0" />
40-
<PackageVersion Include="Telegram.Bot" Version="22.0.0" />
40+
<PackageVersion Include="Telegram.Bot" Version="22.0.1" />
4141
</ItemGroup>
4242
</Project>

0 commit comments

Comments
 (0)