1.2.0-rc.1 #58
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
name: Release Workflow | |
on: | |
release: | |
types: [created, published] | |
jobs: | |
build-and-release: | |
permissions: | |
contents: write | |
runs-on: ubuntu-22.04 | |
if: > | |
(github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')) || | |
(github.event_name == 'release' && github.event.action == 'created') | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
- name: Cache Cargo Registry and Build Output | |
uses: actions/cache@v2 | |
with: | |
path: | | |
~/.cargo/registry | |
~/.cargo/git | |
target | |
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} | |
restore-keys: ${{ runner.os }}-cargo- | |
- name: Install Rust toolchain | |
run: | | |
rustup update stable | |
rustup default stable | |
- name: Build release binary | |
run: | | |
cargo build --release --verbose | |
strip target/release/near-lake | |
cp target/release/near-lake near-lake | |
- name: Determine UPLOAD_URL | |
run: | | |
if [[ "${{ github.event_name }}" == "push" ]]; then | |
TAG_NAME=${GITHUB_REF#refs/tags/} | |
RELEASE_RESPONSE=$(curl -s -X GET -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" "https://api.github.com/repos/${{ github.repository }}/releases/tags/$TAG_NAME") | |
UPLOAD_URL=$(echo "$RELEASE_RESPONSE" | jq -r .upload_url) | |
echo "UPLOAD_URL=$UPLOAD_URL" >> $GITHUB_ENV | |
else | |
echo "UPLOAD_URL=${{ github.event.release.upload_url }}" >> $GITHUB_ENV | |
fi | |
- name: Upload release asset | |
uses: actions/[email protected] | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ env.UPLOAD_URL }} | |
asset_path: ./near-lake | |
asset_name: near-lake | |
asset_content_type: application/octet-stream |