Additional tagging changes found while deploying (#191) #5
Workflow file for this run
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
on: | |
push: | |
tags: | |
- test-server-v* | |
name: Release Test Server | |
jobs: | |
create-release: | |
name: Create release | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
# https://github.community/t5/GitHub-Actions/How-to-get-just-the-tag-name/m-p/44937/highlight/true#M5978 | |
- name: Get the version | |
id: get_version | |
run: | | |
set -x | |
version=${GITHUB_REF/refs\/tags\//} | |
echo VERSION=$version >> $GITHUB_ENV | |
# check if this is a "preview" release and should be marked as "prerelease" in GitHub releases | |
if [[ $version == *"preview"* ]]; then | |
echo PRERELEASE=true >> $GITHUB_ENV | |
else | |
echo PRERELEASE=false >> $GITHUB_ENV | |
fi | |
shell: bash | |
- name: Create GitHub release | |
id: release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: ${{ env.VERSION }} | |
release_name: ${{ env.VERSION }} | |
prerelease: ${{ env.PRERELEASE }} | |
- name: Save artifacts | |
run: | | |
mkdir artifacts | |
echo "${{ steps.release.outputs.upload_url }}" | tee artifacts/release-upload-url | |
echo $VERSION | tee artifacts/release-version | |
- name: Upload artifacts | |
uses: actions/upload-artifact@v2 | |
with: | |
name: artifacts | |
path: artifacts | |
release: | |
name: Build and Upload | |
needs: ['create-release'] | |
strategy: | |
matrix: | |
include: | |
- build: linux | |
os: ubuntu-latest | |
target: x86_64-unknown-linux-musl | |
cross: false | |
- build: arm-v7 | |
os: ubuntu-latest | |
target: armv7-unknown-linux-musleabihf | |
linker: gcc-arm-linux-gnueabihf | |
cross: true | |
- build: aarch64 | |
os: ubuntu-latest | |
target: aarch64-unknown-linux-musl | |
linker: gcc-aarch64-linux-gnu | |
cross: true | |
- build: macos-x86 | |
os: macos-latest | |
cross: false | |
# https://docs.github.com/en/actions/using-github-hosted-runners/about-larger-runners/about-larger-runners | |
# macos-latest-xlarge or macos-13-xlarge are running on arm64 (m1) | |
- build: macos-aarch64 | |
os: macos-latest-xlarge | |
cross: false | |
- build: windows | |
os: windows-latest | |
cross: false | |
runs-on: ${{ matrix.os }} | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Download artifacts | |
uses: actions/download-artifact@v2 | |
with: | |
name: artifacts | |
path: artifacts | |
- name: Get upload data | |
id: upload_data | |
shell: bash | |
run: | | |
release_upload_url="$(cat artifacts/release-upload-url)" | |
echo "RELEASE_UPLOAD_URL=$release_upload_url" >> $GITHUB_ENV | |
release_version="$(cat artifacts/release-version)" | |
echo "VERSION=$release_version" >> $GITHUB_ENV | |
- name: Install Linker | |
if: matrix.cross | |
run: | | |
sudo apt update | |
sudo apt install ${{ matrix.linker }} | |
- name: Build for non-Linux # Windows and MacOS | |
uses: actions-rs/toolchain@v1 | |
if: matrix.os != 'ubuntu-latest' | |
with: | |
profile: minimal | |
toolchain: stable | |
override: true | |
- uses: actions-rs/cargo@v1 | |
if: matrix.os != 'ubuntu-latest' | |
with: | |
command: build | |
args: -q --release --bin test-server | |
# https://github.com/actions-rs/cargo#cross-compilation | |
- name: Build with cross # ARM builds | |
uses: actions-rs/toolchain@v1 | |
if: matrix.os == 'ubuntu-latest' | |
with: | |
profile: minimal | |
toolchain: stable | |
target: ${{ matrix.target }} | |
override: true | |
- uses: actions-rs/cargo@v1 | |
if: matrix.os == 'ubuntu-latest' | |
with: | |
use-cross: true | |
command: build | |
args: -q --release --target ${{ matrix.target }} --bin test-server | |
- name: Compress for Linux/Arm | |
if: matrix.os == 'ubuntu-latest' | |
run: | | |
TARGET=$(echo "${{ matrix.target }}" | sed -e "s/-musl.*//" -e "s/-unknown//") | |
asset_name="test-server-$VERSION-$TARGET.tar.xz" | |
echo "ASSET_NAME=$asset_name" >> $GITHUB_ENV | |
XZ_OPT=-9 tar -C ./target/${{ matrix.target }}/release/ -cJf $asset_name test-server | |
- name: Compress for Windows | |
if: matrix.os == 'windows-latest' | |
shell: bash | |
run: | | |
asset_name="test-server-$VERSION-x86_64-windows.zip" | |
echo "ASSET_NAME=$asset_name" >> $GITHUB_ENV | |
7z a -mm=Deflate64 -mfb=258 -mpass=15 $asset_name ./target/release/test-server.exe | |
- name: Compress for macOS x86 | |
if: matrix.os == 'macos-latest' | |
run: | | |
asset_name="test-server-$VERSION-x86_64-apple-darwin.tar.xz" | |
echo "ASSET_NAME=$asset_name" >> $GITHUB_ENV | |
XZ_OPT=-9 tar -C ./target/release/ -cJf $asset_name test-server | |
- name: Compress for macOS aarch64 | |
if: matrix.os == 'macos-latest-xlarge' | |
run: | | |
asset_name="test-server-$VERSION-aarch64-apple-darwin.tar.xz" | |
echo "ASSET_NAME=$asset_name" >> $GITHUB_ENV | |
XZ_OPT=-9 tar -C ./target/release/ -cJf $asset_name test-server | |
- name: Upload release asset | |
uses: actions/[email protected] | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ env.RELEASE_UPLOAD_URL }} | |
asset_path: ${{ env.ASSET_NAME }} | |
asset_name: ${{ env.ASSET_NAME }} | |
asset_content_type: application/octet-stream |