-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add new workflow for test-server release
- Loading branch information
Showing
1 changed file
with
117 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
on: | ||
push: | ||
tags: | ||
- test-server-v* | ||
|
||
name: Release Test Server | ||
jobs: | ||
create-release: | ||
name: Create release | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
# 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 ::set-env name=VERSION::$version | ||
# check if this is a "preview" release and should be marked as "prerelease" in GitHub releases | ||
if [[ $version == *"preview"* ]]; then | ||
echo ::set-env name=PRERELEASE::true | ||
else | ||
echo ::set-env name=PRERELEASE::false | ||
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@v1 | ||
with: | ||
name: artifacts | ||
path: artifacts | ||
|
||
release: | ||
name: Build and Upload | ||
needs: ['create-release'] | ||
strategy: | ||
matrix: | ||
os: [ubuntu-latest, windows-latest, macos-latest] | ||
runs-on: ${{ matrix.os }} | ||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Download artifacts | ||
uses: actions/download-artifact@v1 | ||
with: | ||
name: artifacts | ||
path: artifacts | ||
|
||
- name: Get upload data | ||
id: upload_data | ||
shell: bash | ||
run: | | ||
release_upload_url="$(cat artifacts/release-upload-url)" | ||
echo "::set-env name=RELEASE_UPLOAD_URL::$release_upload_url" | ||
release_version="$(cat artifacts/release-version)" | ||
echo "::set-env name=VERSION::$release_version" | ||
- name: Build | ||
uses: actions-rs/toolchain@v1 | ||
with: | ||
profile: minimal | ||
toolchain: stable | ||
override: true | ||
- uses: actions-rs/cargo@v1 | ||
with: | ||
command: build | ||
args: -q --release --bin test-server | ||
|
||
- name: Compress for Linux | ||
if: matrix.os == 'ubuntu-latest' | ||
run: | | ||
asset_name="test-server-$VERSION-linux-x86_64.tar.xz" | ||
echo "::set-env name=ASSET_NAME::$asset_name" | ||
XZ_OPT=-9 tar -C ./target/release/ -cJf $asset_name test-server | ||
- name: Compress for Windows | ||
if: matrix.os == 'windows-latest' | ||
shell: bash | ||
run: | | ||
asset_name="test-server-$VERSION-windows-x86_64.zip" | ||
echo "::set-env name=ASSET_NAME::$asset_name" | ||
7z a -mm=Deflate64 -mfb=258 -mpass=15 $asset_name ./target/release/test-server.exe | ||
- name: Compress for macOS | ||
if: matrix.os == 'macos-latest' | ||
run: | | ||
asset_name="test-server-$VERSION-apple-darwin-x86_64.tar.xz" | ||
echo "::set-env name=ASSET_NAME::$asset_name" | ||
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 |