Release #2
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: # manual trigger release | |
inputs: | |
create_release: | |
description: 'Create new release' | |
required: true | |
type: boolean | |
release_version: | |
description: "Version (e.g. 1.0.0)" | |
required: true | |
type: string | |
jobs: | |
build: | |
name: build | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
build: [linux-x86_64, macos-x86_64, macos-arm64] | |
include: | |
- build: linux-x86_64 | |
os: ubuntu-20.04 | |
rust: nightly | |
target: x86_64-unknown-linux-gnu | |
archive-name: server-assistant-x86_64-unknown-linux-gnu.tar.gz | |
bin-path: linux-x86_64-binary | |
- build: macos-x86_64 | |
os: macos-latest | |
rust: nightly | |
target: x86_64-apple-darwin | |
archive-name: server-assistant-x86_64-apple-darwin.tar.gz | |
bin-path: macos-x86_64-binary | |
- build: macos-arm64 | |
os: macos-latest | |
rust: nightly | |
target: aarch64-apple-darwin | |
archive-name: server-assistant-aarch64-apple-darwin.tar.gz | |
bin-path: macos-arm64-binary | |
fail-fast: false | |
steps: | |
- name: Checkout repository | |
id: checkout | |
uses: actions/checkout@v3 | |
- name: Install Rust | |
uses: actions-rs/toolchain@v1 | |
with: | |
toolchain: ${{ matrix.rust }} | |
profile: minimal | |
override: true | |
target: ${{ matrix.target }} | |
- name: Install dependencies | |
if: matrix.build == 'linux-x86_64' | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y build-essential libssl-dev pkg-config | |
rustup target add ${{ matrix.target }} | |
- name: Build binary | |
run: cargo build --verbose --release --target ${{ matrix.target }} | |
env: | |
RUST_BACKTRACE: 1 | |
- name: Strip binary (linux and macos) | |
if: matrix.build == 'linux-x86_64' || matrix.build == 'macos-x86_64' || matrix.build == 'macos-arm64' | |
run: | | |
strip "target/${{ matrix.target }}/release/kw-search-server" | |
ls -al "target/${{ matrix.target }}/release/kw-search-server" | |
- name: Build archive | |
shell: bash | |
run: | | |
mkdir archive | |
# cp LICENSE README.md archive/ | |
cd archive | |
if [ "${{ matrix.build }}" = "windows" ]; then | |
cp "../target/${{ matrix.target }}/release/kw-search-server.exe" ./ | |
7z a "${{ matrix.archive-name }}" kw-search-server.exe | |
fi | |
if [ "${{ matrix.build }}" = "linux-x86_64" ]; then | |
cp "../target/${{ matrix.target }}/release/kw-search-server" ./ | |
sha256sum kw-search-server > SHA256SUM | |
echo "Debug info(SHA256SUM):" | |
cat SHA256SUM | |
tar -czf "${{ matrix.archive-name }}" SHA256SUM kw-search-server | |
fi | |
if [ "${{ matrix.build }}" = "macos-x86_64" ] || [ "${{ matrix.build }}" = "macos-arm64" ]; then | |
cp "../target/${{ matrix.target }}/release/kw-search-server" ./ | |
shasum -a 256 kw-search-server > SHA256SUM | |
echo "Debug info(SHA256SUM):" | |
cat SHA256SUM | |
tar -czf "${{ matrix.archive-name }}" SHA256SUM kw-search-server | |
fi | |
ls -al | |
- name: Upload archive | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ matrix.bin-path }} | |
path: archive/${{ matrix.archive-name }} | |
release: | |
name: release | |
runs-on: ubuntu-latest | |
needs: build | |
steps: | |
- name: Download artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
name: linux-x86_64-binary | |
path: linux-x86_64-binary | |
- name: Download artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
name: macos-x86_64-binary | |
path: macos-x86_64-binary | |
- name: Download artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
name: macos-arm64-binary | |
path: macos-arm64-binary | |
- name: Display structure of downloaded files | |
run: | | |
ls -al | |
ls -al linux-x86_64-binary | |
ls -al macos-x86_64-binary | |
ls -al macos-arm64-binary | |
- name: Tag and release names | |
id: tag_and_release_names | |
run: | | |
echo "tag_name=${{ github.event.inputs.release_version }}" >> $GITHUB_OUTPUT | |
echo "release_name=kw-search-server ${{ github.event.inputs.release_version }}" >> $GITHUB_OUTPUT | |
- name: Create Release and Upload Release Asset | |
if: ${{ github.event.inputs.create_release == 'true' && github.ref == 'refs/heads/main'}} | |
uses: softprops/action-gh-release@v2 | |
with: | |
name: ${{ steps.tag_and_release_names.outputs.release_name }} | |
tag_name: ${{ steps.tag_and_release_names.outputs.tag_name }} | |
body: TODO New Release. | |
draft: true | |
prerelease: true | |
files: | | |
linux-x86_64-binary/* | |
macos-x86_64-binary/* | |
macos-arm64-binary/* |