mirror of
https://github.com/Xithrius/twitch-tui.git
synced 2024-08-16 09:01:11 +03:00
On tag publish, release binaries are generated
This commit is contained in:
parent
312680edcf
commit
5634b8cada
139
.github/workflows/release.yml
vendored
Normal file
139
.github/workflows/release.yml
vendored
Normal file
@ -0,0 +1,139 @@
|
||||
name: Release OS binaries
|
||||
|
||||
on:
|
||||
release:
|
||||
types:
|
||||
- published
|
||||
|
||||
jobs:
|
||||
create-release:
|
||||
name: create-release
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
outputs:
|
||||
upload_url: ${{ steps.release.outputs.upload_url }}
|
||||
twt_version: ${{ env.TWT_VERSION }}
|
||||
|
||||
steps:
|
||||
- name: Get the release version from the tag
|
||||
shell: bash
|
||||
if: env.TWT_VERSION == ''
|
||||
run: |
|
||||
# Apparently, this is the right way to get a tag name. Really?
|
||||
#
|
||||
# See: https://github.community/t5/GitHub-Actions/How-to-get-just-the-tag-name/m-p/32167/highlight/true#M1027
|
||||
# echo "TWT_VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
|
||||
# echo echo ::set-output name=TWT_VERSION::${GITHUB_REF#refs/tags/}
|
||||
echo "TWT_VERSION=${{ github.ref_name }}" >> $GITHUB_ENV
|
||||
echo "version is: ${{ env.TWT_VERSION }}"
|
||||
|
||||
- name: Create GitHub release
|
||||
id: release
|
||||
uses: actions/create-release@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
with:
|
||||
tag_name: ${{ env.TWT_VERSION }}
|
||||
release_name: ${{ env.TWT_VERSION }}
|
||||
|
||||
build-release:
|
||||
name: build-release
|
||||
needs: ["create-release"]
|
||||
runs-on: ${{ matrix.os }}
|
||||
|
||||
env:
|
||||
CARGO: cargo
|
||||
TARGET_FLAGS: ""
|
||||
TARGET_DIR: ./target
|
||||
RUST_BACKTRACE: 1
|
||||
|
||||
strategy:
|
||||
matrix:
|
||||
build: [linux, macos, win-msvc, win-gnu, win32-msvc]
|
||||
|
||||
include:
|
||||
- build: linux
|
||||
os: ubuntu-18.04
|
||||
rust: stable
|
||||
target: x86_64-unknown-linux-musl
|
||||
|
||||
- build: macos
|
||||
os: macos-latest
|
||||
rust: stable
|
||||
target: x86_64-apple-darwin
|
||||
|
||||
- build: win-msvc
|
||||
os: windows-2019
|
||||
rust: stable
|
||||
target: x86_64-pc-windows-msvc
|
||||
|
||||
- build: win-gnu
|
||||
os: windows-2019
|
||||
rust: stable-x86_64-gnu
|
||||
target: x86_64-pc-windows-gnu
|
||||
|
||||
- build: win32-msvc
|
||||
os: windows-2019
|
||||
rust: stable
|
||||
target: i686-pc-windows-msvc
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
fetch-depth: 1
|
||||
|
||||
- name: Install Rust
|
||||
uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
toolchain: ${{ matrix.rust }}
|
||||
profile: minimal
|
||||
override: true
|
||||
target: ${{ matrix.target }}
|
||||
|
||||
- name: Cargo flags
|
||||
shell: bash
|
||||
run: |
|
||||
echo "TARGET_FLAGS=--target ${{ matrix.target }}" >> $GITHUB_ENV
|
||||
echo "TARGET_DIR=./target/${{ matrix.target }}" >> $GITHUB_ENV
|
||||
|
||||
- name: Show command used for Cargo
|
||||
run: |
|
||||
echo "cargo command is: ${{ env.CARGO }}"
|
||||
echo "target flag is: ${{ env.TARGET_FLAGS }}"
|
||||
echo "target dir is: ${{ env.TARGET_DIR }}"
|
||||
|
||||
- name: Build release binary
|
||||
run: ${{ env.CARGO }} build --verbose --release ${{ env.TARGET_FLAGS }}
|
||||
|
||||
- name: Strip release binary (linux and macos)
|
||||
if: matrix.build == 'linux' || matrix.build == 'macos'
|
||||
run: strip "target/${{ matrix.target }}/release/twitch-tui"
|
||||
|
||||
- name: Build archive
|
||||
shell: bash
|
||||
run: |
|
||||
staging="twitch-tui-${{ needs.create-release.outputs.twt_version }}-${{ matrix.target }}"
|
||||
mkdir -p "$staging"
|
||||
cp {README.md,LICENSE} "$staging/"
|
||||
if [ "${{ matrix.os }}" = "windows-2019" ]; then
|
||||
cp "target/${{ matrix.target }}/release/twitch-tui.exe" "$staging/"
|
||||
7z a "$staging.zip" "$staging"
|
||||
echo "ASSET=$staging.zip" >> $GITHUB_ENV
|
||||
else
|
||||
cp "target/${{ matrix.target }}/release/twitch-tui" "$staging/"
|
||||
tar czf "$staging.tar.gz" "$staging"
|
||||
echo "ASSET=$staging.tar.gz" >> $GITHUB_ENV
|
||||
fi
|
||||
|
||||
- name: Upload release archive
|
||||
uses: actions/upload-release-asset@v1.0.1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
with:
|
||||
upload_url: ${{ needs.create-release.outputs.upload_url }}
|
||||
asset_path: ${{ env.ASSET }}
|
||||
asset_name: ${{ env.ASSET }}
|
||||
asset_content_type: application/octet-stream
|
Loading…
Reference in New Issue
Block a user