forked from CycloneDX/cyclonedx-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
191 lines (174 loc) · 7.34 KB
/
Copy pathrelease.yml
File metadata and controls
191 lines (174 loc) · 7.34 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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
# This workflow is used for publishing the binaries.
#
# Before triggering a release the `semver.txt` file should be updated in the
# relevant branch.
#
# When commiting the version change in `semver.txt` the commit message is
# important as it will be used for the release in GitHub.
#
# For an example commit browse to
# https://github.com/CycloneDX/cyclonedx-dotnet/commit/d110af854371374460430bb8438225a7d7a84274.
#
# The resulting release is here
# https://github.com/CycloneDX/cyclonedx-dotnet/releases/tag/v1.0.0.
#
# Releases are triggered manually. This can be done by browsing to
# https://github.com/CycloneDX/cyclonedx-cli/actions?query=workflow%3ARelease
# and selecting "Run workflow". If releasing a patch for a previous version
# make sure the correct branch is selected. It will default to the default
# branch.
name: Release
on:
workflow_dispatch
jobs:
release:
name: Release
runs-on: ubuntu-20.04
timeout-minutes: 30
outputs:
# Used by the release-osx-arm64 job to upload the osx-arm64 binary
release_upload_url: ${{ steps.create_release.outputs.upload_url }}
steps:
- uses: actions/checkout@v3.1.0
- uses: actions/setup-dotnet@v3.0.2
with:
dotnet-version: '6.0'
# The tests should have already been run during the PR workflow, so this is really just a sanity check
- name: Tests
run: dotnet test
# Create binaries
- name: Create binaries
id: create_binaries
run: |
VERSION=`cat semver.txt`
echo "##[set-output name=version;]$VERSION"
REPO=cyclonedx/cyclonedx-cli
dotnet build --configuration Release
mkdir bin
for runtime in linux-x64 linux-musl-x64 linux-arm linux-arm64 win-x64 win-x86 win-arm win-arm64 osx-x64
do
dotnet publish src/cyclonedx/cyclonedx.csproj -r $runtime --configuration Release /p:Version=$VERSION --self-contained true /p:PublishSingleFile=true /p:IncludeNativeLibrariesInSingleFile=true /p:IncludeNativeLibrariesForSelfExtract=true --output bin/$runtime
done
- name: Create github release and git tag for release
id: create_release
uses: actions/create-release@v1.1.4
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
release_name: ${{ steps.create_binaries.outputs.version }}
tag_name: v${{ steps.create_binaries.outputs.version }}
draft: false
prerelease: false
- name: Upload binary to github release
uses: actions/upload-release-asset@v1.0.2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: bin/linux-x64/cyclonedx
asset_name: cyclonedx-linux-x64
asset_content_type: application/octet-stream
- name: Upload binary to github release
uses: actions/upload-release-asset@v1.0.2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: bin/linux-musl-x64/cyclonedx
asset_name: cyclonedx-linux-musl-x64
asset_content_type: application/octet-stream
- name: Upload binary to github release
uses: actions/upload-release-asset@v1.0.2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: bin/linux-arm/cyclonedx
asset_name: cyclonedx-linux-arm
asset_content_type: application/octet-stream
- name: Upload binary to github release
uses: actions/upload-release-asset@v1.0.2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: bin/linux-arm64/cyclonedx
asset_name: cyclonedx-linux-arm64
asset_content_type: application/octet-stream
- name: Upload binary to github release
uses: actions/upload-release-asset@v1.0.2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: bin/win-x64/cyclonedx.exe
asset_name: cyclonedx-win-x64.exe
asset_content_type: application/octet-stream
- name: Upload binary to github release
uses: actions/upload-release-asset@v1.0.2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: bin/win-x86/cyclonedx.exe
asset_name: cyclonedx-win-x86.exe
asset_content_type: application/octet-stream
- name: Upload binary to github release
uses: actions/upload-release-asset@v1.0.2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: bin/win-arm/cyclonedx.exe
asset_name: cyclonedx-win-arm.exe
asset_content_type: application/octet-stream
- name: Upload binary to github release
uses: actions/upload-release-asset@v1.0.2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: bin/win-arm64/cyclonedx.exe
asset_name: cyclonedx-win-arm64.exe
asset_content_type: application/octet-stream
- name: Upload binary to github release
uses: actions/upload-release-asset@v1.0.2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: bin/osx-x64/cyclonedx
asset_name: cyclonedx-osx-x64
asset_content_type: application/octet-stream
# Binaries for Apple silicon must be signed, which can only be achieved on macOS.
# See https://github.com/dotnet/runtime/issues/49091#issuecomment-797029172
release-osx-arm64:
name: Release osx-arm64
needs: release
runs-on: macos-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v3.1.0
- uses: actions/setup-dotnet@v3.0.2
with:
dotnet-version: '6.0'
- name: Create binary
run: |
VERSION=`cat semver.txt`
echo "##[set-output name=version;]$VERSION"
dotnet build --configuration Release
mkdir bin
dotnet publish src/cyclonedx/cyclonedx.csproj -r osx-arm64 --configuration Release /p:Version=$VERSION --self-contained true /p:PublishSingleFile=true /p:IncludeNativeLibrariesInSingleFile=true /p:IncludeNativeLibrariesForSelfExtract=true --output bin/osx-arm64
# It is enough to "ad-hoc" sign the binary, we don't need a valid developer certificate for now.
- name: Sign binary
run: |
codesign -f -s - bin/osx-arm64/cyclonedx
- name: Upload binary to github release
uses: actions/upload-release-asset@v1.0.2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.release.outputs.release_upload_url }}
asset_path: bin/osx-arm64/cyclonedx
asset_name: cyclonedx-osx-arm64
asset_content_type: application/octet-stream