Skip to content

chore: Release

chore: Release #19

Workflow file for this run

name: Publish GitHub releases
on:
workflow_dispatch:
push:
tags:
- '[v]?[0-9]+.[0-9]+.[0-9]+'
jobs:
publish-binaries:
name: Publishing for ${{ matrix.job.os }}
runs-on: ${{ matrix.job.os }}
strategy:
matrix:
job:
- os: macos-latest
os-name: macos
target: x86_64-apple-darwin
architecture: x86_64
binary-postfix: ""
use-cross: false
- os: ubuntu-latest
os-name: linux
target: x86_64-unknown-linux-musl
architecture: x86_64
binary-postfix: ""
use-cross: false
- os: windows-latest
os-name: windows
target: x86_64-pc-windows-msvc
architecture: x86_64
binary-postfix: ".exe"
use-cross: false
# TODO: re-enable this but need to figure out how to cross-compile for ARM64 using MUSL
# Seems like the details are https://jensd.be/1126/linux/cross-compiling-for-arm-or-aarch64-on-debian-or-ubuntu
#- os: ubuntu-latest
# os-name: linux
# target: aarch64-unknown-linux-musl
# architecture: arm64
# binary-postfix: ""
# use-cross: true
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
target: ${{ matrix.job.target }}
- uses: Swatinem/rust-cache@v1
- name: Install Ubuntu MUSL deps
run: |
sudo apt-get install musl musl-dev musl-tools
if: matrix.job.os-name == 'linux'
- name: Cargo build
uses: actions-rs/cargo@v1
with:
command: build
use-cross: ${{ matrix.job.use-cross }}
args: --release --target ${{ matrix.job.target }} --package ssstar-cli
env:
RUSTFLAGS: '-C target-feature=+crt-static'
- name: install strip command
shell: bash
run: |
if [[ ${{ matrix.job.target }} == aarch64-unknown-linux-gnu ]]; then
sudo apt update
sudo apt-get install -y binutils-aarch64-linux-gnu
fi
- name: Packaging final binary
shell: bash
run: |
cd target/${{ matrix.job.target }}/release
####### reduce binary size by removing debug symbols #######
BINARY_NAME=ssstar${{ matrix.job.binary-postfix }}
if [[ ${{ matrix.job.target }} == aarch64-unknown-linux-gnu ]]; then
GCC_PREFIX="aarch64-linux-gnu-"
else
GCC_PREFIX=""
fi
"$GCC_PREFIX"strip $BINARY_NAME
########## create tar.gz ##########
if [[ "${{ startsWith(github.ref, 'refs/tags/v') }}" == "true" ]]; then
VERSION=${GITHUB_REF/refs\/tags\//}
else
VERSION=master
fi
RELEASE_NAME=ssstar-${VERSION}-${{ matrix.job.os-name }}-${{ matrix.job.architecture }}
tar czvf $RELEASE_NAME.tar.gz $BINARY_NAME
########## create sha256 ##########
if [[ ${{ runner.os }} == 'Windows' ]]; then
certutil -hashfile $RELEASE_NAME.tar.gz sha256 | grep -E [A-Fa-f0-9]{64} > $RELEASE_NAME.sha256
else
shasum -a 256 $RELEASE_NAME.tar.gz > $RELEASE_NAME.sha256
fi
- name: Releasing assets
uses: softprops/action-gh-release@v1
with:
files: |
target/${{ matrix.job.target }}/release/ssstar-*.tar.gz
target/${{ matrix.job.target }}/release/ssstar-*.sha256
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
if: startsWith(github.ref, 'refs/tags/v')
publish-docker:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Build docker image
shell: bash
run: |
# Tag the docker image with the full semver, major.minor, and major
version=$(cargo metadata --format-version 1 --manifest-path ssstar-cli/Cargo.toml \
| jq -r ".packages[]|select(.name == \"ssstar-cli\")|.version")
major_minor=$(echo $version | sed -r 's/([0-9]+\.[0-9]+).*$/\1/')
major=$(echo $version | sed -r 's/([0-9]+)\.[0-9]+.*$/\1/')
docker build . \
--tag ssstar:latest \
--tag ghcr.io/elastio/ssstar:latest \
--tag ghcr.io/elastio/ssstar:$version \
--tag ghcr.io/elastio/ssstar:$major_minor \
--tag ghcr.io/elastio/ssstar:$major
docker images
- name: Publish to GitHub Container Registry
run: |
echo $GITHUB_TOKEN | docker login ghcr.io -u USERNAME --password-stdin
docker push --all-tags ghcr.io/elastio/ssstar
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
if: startsWith(github.ref, 'refs/tags/v')