forked from MichalStrehovsky/PublishAotCompressed
-
Notifications
You must be signed in to change notification settings - Fork 0
128 lines (109 loc) · 4.91 KB
/
main.yml
File metadata and controls
128 lines (109 loc) · 4.91 KB
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
name: CI
on:
push:
branches: [ master ]
tags:
- 'v*'
pull_request:
branches: [ master ]
workflow_dispatch:
inputs:
version:
description: 'Release version to create (e.g., v1.0.0-preview or 1.0.0-preview)'
required: true
jobs:
build_and_test:
runs-on: macos-latest
name: Build and test on macOS
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '9.0.x'
include-prerelease: true
- name: Install UPX
run: brew install upx
- name: Determine version from tag or input
id: version
run: |
if [[ "${{ github.ref }}" == refs/tags/* ]]; then
# Triggered by tag push
VERSION="${{ github.ref_name }}"
echo "Triggered by tag: ${VERSION}"
elif [[ -n "${{ github.event.inputs.version }}" ]]; then
# Triggered by workflow_dispatch
VERSION="${{ github.event.inputs.version }}"
echo "Triggered by workflow_dispatch: ${VERSION}"
else
# Triggered by push to master or PR
VERSION=""
echo "Triggered by push/PR: No version"
fi
if [[ -n "${VERSION}" ]]; then
# Remove 'v' prefix if present for NuGet
VERSION_NO_V="${VERSION#v}"
echo "nuget_version=${VERSION_NO_V}" >> $GITHUB_OUTPUT
echo "git_tag=v${VERSION_NO_V}" >> $GITHUB_OUTPUT
echo "should_release=true" >> $GITHUB_OUTPUT
echo "NuGet Version: ${VERSION_NO_V}"
echo "Git Tag: v${VERSION_NO_V}"
else
echo "should_release=false" >> $GITHUB_OUTPUT
echo "No release will be created"
fi
- name: Build Package (CI - No Release)
if: ${{ steps.version.outputs.should_release != 'true' }}
run: |
dotnet build -t:Pack src/PublishAotCompressed.macOS.nuproj
- name: Test - Build for macOS (should skip UPX)
if: ${{ steps.version.outputs.should_release != 'true' }}
run: |
dotnet publish -r osx-arm64 -c Release test/Hello.csproj
ls -lh test/bin/Release/net9.0/osx-arm64/publish/
- name: Build Package (Release)
if: ${{ steps.version.outputs.should_release == 'true' }}
run: dotnet build -t:Pack src/PublishAotCompressed.macOS.nuproj -p:Version=${{ steps.version.outputs.nuget_version }}
- name: Archive NuGet Package
if: ${{ steps.version.outputs.should_release == 'true' }}
uses: actions/upload-artifact@v4
with:
name: PublishAotCompressed.macOS.${{ steps.version.outputs.nuget_version }}.nupkg
path: src/bin/Debug/PublishAotCompressed.macOS.${{ steps.version.outputs.nuget_version }}.nupkg
- name: Publish to NuGet.org
if: ${{ steps.version.outputs.should_release == 'true' }}
run: |
dotnet nuget push src/bin/Debug/PublishAotCompressed.macOS.${{ steps.version.outputs.nuget_version }}.nupkg \
--api-key ${{ secrets.NUGET_API_KEY }} \
--source https://api.nuget.org/v3/index.json \
--skip-duplicate
- name: Create Release Tag
if: ${{ steps.version.outputs.should_release == 'true' && github.event_name == 'workflow_dispatch' }}
run: |
git config user.name github-actions
git config user.email github-actions@github.com
git tag ${{ steps.version.outputs.git_tag }}
git push origin ${{ steps.version.outputs.git_tag }}
- name: Create GitHub Release
if: ${{ steps.version.outputs.should_release == 'true' }}
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ steps.version.outputs.git_tag }}
name: ${{ steps.version.outputs.git_tag }}
body: |
## PublishAotCompressed.macOS ${{ steps.version.outputs.git_tag }}
Automatic UPX compression for .NET Native AOT cross-compilation from macOS.
### Installation
```xml
<PackageReference Include="PublishAotCompressed.macOS" Version="${{ steps.version.outputs.nuget_version }}" />
```
### Quick Start
```bash
dotnet publish -r win-x64 -c Release
```
See [README.md](https://github.com/interface95/PublishAotCompressed.macOS/blob/master/README.md) for details.
files: src/bin/Debug/PublishAotCompressed.macOS.${{ steps.version.outputs.nuget_version }}.nupkg
prerelease: ${{ contains(steps.version.outputs.nuget_version, 'preview') || contains(steps.version.outputs.nuget_version, 'alpha') || contains(steps.version.outputs.nuget_version, 'beta') }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}