-
Notifications
You must be signed in to change notification settings - Fork 0
160 lines (139 loc) · 4.75 KB
/
release.yml
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
name: Release
on:
workflow_dispatch:
inputs:
version:
description: '릴리스 버전 (예: 1.0.0)'
required: true
type: string
default: '4.1.0'
branch:
description: '릴리스 브랜치 이름 (예: release-1.0.0)'
required: true
type: string
default: 'main'
env:
RELEASE_VERSION: ${{ github.event.inputs.version }}
jobs:
check-out-branch:
runs-on: ubuntu-latest
outputs:
commit_sha: ${{ steps.get_sha.outputs.commit_sha }}
steps:
- uses: actions/checkout@v3
with:
ref: ${{ github.event.inputs.branch }}
- name: Get commit SHA
id: get_sha
run: echo "commit_sha=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
build-and-package:
needs: check-out-branch
runs-on: ${{ matrix.os }}
container: ${{ matrix.container }}
strategy:
matrix:
include:
- target: x86_64-unknown-linux-musl
packaging: tar
name: alpine
os: ubuntu-latest
container: alpine:latest
- target: x86_64-unknown-linux-gnu
packaging: tar
name: ubuntu
os: ubuntu-latest
container: ubuntu:latest
- target: x86_64-unknown-linux-gnu
packaging: rpm
name: centos
os: ubuntu-latest
container: rockylinux:9
- target: x86_64-apple-darwin
packaging: tar
name: macos
os: macos-latest
container: ~
steps:
- uses: actions/checkout@v3
with:
ref: ${{ github.event.inputs.branch }}
- name: Install musl-tools (for Alpine)
if: matrix.target == 'x86_64-unknown-linux-musl'
run: |
sudo apk add curl wget gcc musl-dev
- name: Install RPM build tools
if: matrix.packaging == 'rpm'
run: |
dnf install -y rpm-build
- name: Install Rust (${{ matrix.os }}, ${{ matrix.name }})
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
target: ${{ matrix.target }}
override: true
- name: Build
uses: actions-rs/cargo@v1
with:
command: build
args: --release --target ${{ matrix.target }}
- name: Create RPM spec file
if: matrix.packaging == 'rpm'
run: |
BINARY_PATH="$(pwd)/target/x86_64-unknown-linux-gnu/release/mlperf-log-parser"
cat > mlperf-log-parser.spec << EOF
Name: mlperf-log-parser
Version: ${{ env.RELEASE_VERSION }}
Release: 1%{?dist}
Summary: MLPerf Log Parser Tool
License: MIT
URL: https://github.com/$GITHUB_REPOSITORY
%description
A tool for parsing MLPerf log files
%install
mkdir -p %{buildroot}%{_bindir}
install -m 755 ${BINARY_PATH} %{buildroot}%{_bindir}/mlperf-log-parser
%files
%{_bindir}/mlperf-log-parser
%changelog
* $(date '+%a %b %d %Y') GitHub Action <[email protected]> - ${{ env.RELEASE_VERSION }}-1
- Automated RPM release
EOF
- name: Build RPM package
if: matrix.packaging == 'rpm'
run: |
mkdir -p ~/rpmbuild/{SPECS,SOURCES,BUILD,RPMS,SRPMS}
cp mlperf-log-parser.spec ~/rpmbuild/SPECS/
rpmbuild -bb ~/rpmbuild/SPECS/mlperf-log-parser.spec --define "_topdir $HOME/rpmbuild" --define "_builddir $(pwd)"
cp ~/rpmbuild/RPMS/x86_64/*.rpm ./mlperf-log-parser-${{ matrix.name }}-x86_64.rpm
- name: Package Binary
if: matrix.packaging == 'tar'
run: |
cd target/${{ matrix.target }}/release
tar czf ../../../mlperf-log-parser-${{ matrix.name }}-x86_64.tar.gz mlperf-log-parser
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
name: release-artifacts-${{ matrix.name }}
path: mlperf-log-parser-*-x86_64.*
retention-days: 1
create-release:
needs: build-and-package
runs-on: ubuntu-latest
steps:
- name: Download all artifacts
uses: actions/download-artifact@v3
with:
path: artifacts
- name: Move artifacts to root
run: |
find artifacts -type f -name "mlperf-log-parser-*-x86_64.*" -exec mv {} . \;
- name: Create Release
uses: softprops/action-gh-release@v1
with:
name: Release v${{ env.RELEASE_VERSION }}
tag_name: v${{ env.RELEASE_VERSION }}
files: |
mlperf-log-parser-*-x86_64.*
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}