Release #8
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 Rust | |
uses: actions-rs/toolchain@v1 | |
with: | |
profile: minimal | |
toolchain: stable | |
target: ${{ matrix.target }} | |
override: true | |
- name: Install musl-tools (for Alpine) | |
if: matrix.target == 'x86_64-unknown-linux-musl' | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y musl-tools | |
- name: Install RPM build tools | |
if: matrix.packaging == 'rpm' | |
run: | | |
dnf install -y rpm-build | |
- 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 <action@github.com> - ${{ 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 }} |