Skip to content

Commit 899095d

Browse files
committed
Add workflow to publish a release
1 parent 44e5a14 commit 899095d

1 file changed

Lines changed: 90 additions & 0 deletions

File tree

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
name: Build and Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
8+
permissions:
9+
contents: write
10+
11+
jobs:
12+
build:
13+
runs-on: ubuntu-latest
14+
strategy:
15+
matrix:
16+
runtime: ['win-x64', 'linux-x64']
17+
include:
18+
- runtime: win-x64
19+
os: windows
20+
extension: .exe
21+
- runtime: linux-x64
22+
os: linux
23+
extension: ''
24+
25+
steps:
26+
- uses: actions/checkout@v3
27+
28+
- name: Setup .NET
29+
uses: actions/setup-dotnet@v3
30+
with:
31+
dotnet-version: 9.0.x
32+
33+
- name: Find terminal app project
34+
id: find-terminal
35+
run: |
36+
# Find the terminal project
37+
TERMINAL_PROJECT=$(find . -name "*.csproj" -type f -exec grep -l "<OutputType>Exe</OutputType>" {} \; | head -n 1)
38+
echo "terminal_project=$TERMINAL_PROJECT" >> $GITHUB_OUTPUT
39+
echo "Found terminal project: $TERMINAL_PROJECT"
40+
41+
- name: Build standalone
42+
run: |
43+
dotnet publish ${{ steps.find-terminal.outputs.terminal_project }} -c Release -r ${{ matrix.runtime }} \
44+
-p:PublishSingleFile=true \
45+
-p:IncludeNativeLibrariesForSelfExtract=true \
46+
--self-contained true \
47+
-o ./publish/
48+
49+
- name: Rename executable
50+
run: |
51+
# Find the executable in the publish directory
52+
FILES=$(find ./publish -type f -executable -not -path "*/\.*" -o -name "*.exe")
53+
for FILE in $FILES; do
54+
# Get just the filename for the destination
55+
EXTENSION="${FILE##*.}"
56+
if [ "$EXTENSION" = "exe" ]; then
57+
EXTENSION="${{ matrix.extension }}"
58+
else
59+
EXTENSION=""
60+
fi
61+
62+
# Rename to your desired format
63+
VERSION="${GITHUB_REF#refs/tags/}"
64+
VERSION="${VERSION#v}"
65+
cp "$FILE" "csrsa-cli-${{ matrix.os }}-${{ matrix.runtime }}-${VERSION}${EXTENSION}"
66+
done
67+
68+
- name: Upload artifacts
69+
uses: actions/upload-artifact@v3
70+
with:
71+
name: builds
72+
path: csrsa-cli-*
73+
retention-days: 1
74+
75+
release:
76+
needs: build
77+
runs-on: ubuntu-latest
78+
steps:
79+
- name: Download artifacts
80+
uses: actions/download-artifact@v3
81+
with:
82+
name: builds
83+
path: ./
84+
85+
- name: Create Release
86+
uses: softprops/action-gh-release@v1
87+
with:
88+
files: csrsa-cli-*
89+
env:
90+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)