Skip to content

Trying to get the tag name right #65

Trying to get the tag name right

Trying to get the tag name right #65

Workflow file for this run

on:
push:
tags:
- 'v*'
name: Release
jobs:
build:
name: Build
env:
# The project name specified in your Cargo.toml
PROJECT_NAME: aderyn
runs-on: ${{ matrix.runner }}
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:
- name: Checkout
uses: actions/checkout@v3
- name: Extract Tag Name
id: extract_tag_name # Assigning an ID to this step
run: echo "::set-output name=tag_name::${GITHUB_REF#refs/tags/}"
- name: Set Environment Variable (Windows)
if: matrix.runner == 'windows-latest'
shell: pwsh
run: |
"TAG_NAME=${GITHUB_REF#refs/tags/}" | Out-File -Append $env:GITHUB_ENV
- name: Set Environment Variable (Non-Windows)
if: matrix.runner != 'windows-latest'
shell: bash
run: |
echo "TAG_NAME=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: "${{ matrix.target }}"
- name: Setup Cache
uses: Swatinem/rust-cache@v2
- name: Build Binary
run: cargo build --verbose --locked --release --target ${{ matrix.target }}
- name: Create Binary
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 }}-${{ env.TAG_NAME }}${BIN_SUFFIX}"
echo "BIN_RELEASE_VERSIONED: $BIN_RELEASE_VERSIONED"
mv "${BIN_OUTPUT}" "./${BIN_RELEASE_VERSIONED}"
echo "BIN_RELEASE_VERSIONED=${BIN_RELEASE_VERSIONED}" >> $GITHUB_ENV
- name: Output Tag Name
run: echo "tag_name=${{ env.TAG_NAME }}" >> $GITHUB_ENV
if: success()
- name: Upload Artifact
uses: actions/upload-artifact@v2
with:
name: ${{ env.BIN_RELEASE_VERSIONED }}
path: ${{ env.BIN_RELEASE_VERSIONED }}
outputs:
tag_name: ${{ steps.extract_tag_name.outputs.tag_name }}
create_release:
needs: build
runs-on: ubuntu-latest
steps:
- name: Download All Artifacts
uses: actions/download-artifact@v2
with:
path: artifacts/
- name: Compress Artifacts
run: |
mkdir compressed
tar -czvf compressed/all_binaries.tar.gz -C artifacts/ .
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ needs.build.outputs.tag_name }}
release_name: "Release ${{ needs.build.outputs.tag_name }}"
draft: false
prerelease: false
- name: Upload Compressed Release Asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./compressed/all_binaries.tar.gz
asset_name: all_binaries.tar.gz
asset_content_type: application/gzip