Skip to content

On v, using github.ref instead of BIN_COMMIT #55

On v, using github.ref instead of BIN_COMMIT

On v, using github.ref instead of BIN_COMMIT #55

Workflow file for this run

on:
push:
tags:
- 'v*'
name: Release
jobs:
create_release:
name: Create Release
runs-on: ubuntu-latest
outputs:
upload_url: ${{ steps.get_upload_url.outputs.upload_url }}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
draft: true
prerelease: true
- name: Get Upload URL
id: get_upload_url
run: |
UPLOAD_URL=$(curl -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
-H "Accept: application/vnd.github.v3+json" \
"https://api.github.com/repos/${{ github.repository }}/releases/tags/${{ github.ref }}" \
| jq -r .upload_url)
echo "::set-output name=upload_url::$UPLOAD_URL"
build:
name: Build
env:
PROJECT_NAME: aderyn
runs-on: ${{ matrix.runner }}
needs: create_release
strategy:
matrix:
include:
- name: linux-amd64
runner: ubuntu-latest
target: x86_64-unknown-linux-gnu
- name: win-amd64
runner: windows-latest
target: x86_64-pc-windows-msvc
- name: macos-amd64
runner: macos-latest
target: x86_64-apple-darwin
- name: macos-arm64
runner: macos-latest
target: aarch64-apple-darwin
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@stable
with:
targets: "${{ matrix.target }}"
- uses: Swatinem/rust-cache@v2
- run: cargo build --verbose --locked --release --target ${{ matrix.target }}
- shell: bash
run: |
BIN_SUFFIX=""
if [[ "${{ matrix.runner }}" == "windows-latest" ]]; then
BIN_SUFFIX=".exe"
fi
BIN_OUTPUT="target/${{ matrix.target }}/release/${PROJECT_NAME}${BIN_SUFFIX}"
BIN_RELEASE_VERSIONED="${PROJECT_NAME}-${{ matrix.name }}-${{ github.ref }}${BIN_SUFFIX}"
mv "${BIN_OUTPUT}" "./${BIN_RELEASE_VERSIONED}"
echo "BIN_RELEASE_VERSIONED=${BIN_RELEASE_VERSIONED}" >> $GITHUB_ENV
- uses: actions/upload-artifact@v2
with:
name: ${{ env.BIN_RELEASE_VERSIONED }}
path: ${{ env.BIN_RELEASE_VERSIONED }}
- uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.create_release.outputs.upload_url }}
asset_path: ${{ env.BIN_RELEASE_VERSIONED }}
asset_name: ${{ env.BIN_RELEASE_VERSIONED }}
asset_content_type: application/octet-stream