Skip to content

Commit

Permalink
ci: auto build and attach after release message
Browse files Browse the repository at this point in the history
  • Loading branch information
fakeboboliu committed Nov 12, 2023
1 parent fe82af9 commit 07edaf4
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 0 deletions.
78 changes: 78 additions & 0 deletions .github/workflows/build-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
name: Build for Release

on:
release:
types: [published]

jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: write

strategy:
matrix:
runtime: [win-x64, linux-x64, osx-x64]
include:
- runtime: win-x64
artifact_path: ./bin/Wpf/Release/net48/win-x64
self_contained: "--no-self-contained"
framework: net48
nt_file: nexttrace_windows_amd64.exe
nt_fn: nexttrace.exe
- runtime: linux-x64
artifact_path: ./bin/Gtk/Release/net6.0/linux-x64
self_contained: "--self-contained"
framework: net6.0
nt_file: nexttrace_linux_amd64
nt_fn: nexttrace
- runtime: osx-x64
artifact_path: ./bin/Mac64/Release/net6.0/osx-x64
self_contained: "--self-contained"
framework: net6.0
nt_file: nexttrace_darwin_amd64
nt_fn: nexttrace

steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 6

- name: Build
run: dotnet build OpenTrace.csproj --runtime ${{ matrix.runtime }} --configuration Release ${{ matrix.self_contained }} -f ${{ matrix.framework }}

- name: Fetch Nexttrace Version
run: |
release="${{ github.event.release.body }} "
echo "ntver=$(echo $release | grep -E -o nexttrace_version:.\*? | cut -d':' -f2)" >> $GITHUB_ENV
- name: Download Nexttrace
uses: robinraju/[email protected]
with:
repository: nxtrace/NTrace-V1
fileName: ${{ matrix.nt_file }}
latest: ${{ env.ntver == '' && true || false }}
tag: ${{ env.ntver }}
token: ${{ secrets.GITHUB_TOKEN }}
out-file-path: ${{ matrix.artifact_path }}

- name: Package
run: |
cd ${{ matrix.artifact_path }}
mv ./nexttrace_* ./${{ matrix.nt_fn }}
chmod +x ./${{ matrix.nt_fn }}
tar -cvzf ../../../../../${{ matrix.runtime }}.tar.gz .
- name: Edit release for ${{ matrix.runtime }}
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: ${{ matrix.runtime }}.tar.gz
asset_name: ${{ matrix.runtime }}.tar.gz
tag: ${{ github.ref }}
1 change: 1 addition & 0 deletions OpenTrace.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="System.Configuration.ConfigurationManager" Version="7.0.0" />
<PackageReference Include="System.Net.Http" Version="4.3.4" />
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" PrivateAssets="All" Version="1.0.3" />
</ItemGroup>

<ItemGroup>
Expand Down

0 comments on commit 07edaf4

Please sign in to comment.