Skip to content

Commit

Permalink
Merge pull request #3 from plebhash/release-bin
Browse files Browse the repository at this point in the history
refactor release bin action
  • Loading branch information
plebhash committed Feb 21, 2024
2 parents ad8c6a4 + fcf7df0 commit aaa44be
Showing 1 changed file with 68 additions and 170 deletions.
238 changes: 68 additions & 170 deletions .github/workflows/release-bin.yaml
Original file line number Diff line number Diff line change
@@ -1,198 +1,96 @@
# as well as releasing binaries of the roles
# (translator, pool, mining_proxy) to github.
# If the binary releases do fail to due to not having tags, force run the `autoversion` workflow
# This workflow is used to create a new release with a binary distribution or SRI roles
# If the binary releases fails due to not having tags, force run the `autoversion` workflow
# on the main branch and merge the resulting PR to create the tags and move them to the main branch.

name: Release Binaries
on:

on:
# Manually run by going to "Actions/Release" in Github and running the workflow
workflow_dispatch:

jobs:
github_release_translator:
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- os: ubuntu-latest
artifact_name: translator_sv2
asset_name: translator_sv2-linux-amd64
# - os: windows-latest
# artifact_name: translator_sv2.exe
# asset_name: translator_sv2-windows-amd64
- os: macos-latest
artifact_name: translator_sv2
asset_name: translator_sv2-macos-amd64


release_pool:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
# The tags are not in scope until we fetch them from main
# This will fail if there are no tags available
- name: fetch tags
run: git fetch origin --tags

# Find the latest translator tag by listing folders in `.git/refs/tags` with pattern `translator_sv2`,
# taking the last one, and setting to `TRANSLATOR_TAG` env variable. This will be used as the "tag" in the
# Build step
- name: set env unix
if: matrix.os == 'ubuntu-latest' || matrix.os == 'macos-latest'
run: echo "TRANSLATOR_TAG=$(echo refs/tags/$(ls .git/refs/tags | grep 'translator_sv2' | tail -n 1))" >> $GITHUB_ENV

# This does not work
- name: set env windows
if: matrix.os == 'windows-latest'
run: echo "$(dir .git/refs/tags | findstr "translator_sv2")"

# This will fail on a Windows build. Must use if statement to check if running on Windows and use `dir` instead)
# `dir` will fail on mac builds
- name: check refs
run: ls .git/refs/tags

# Debugging step to ensure tag is correct
- name: check env
if: matrix.os == 'ubuntu-latest' || matrix.os == 'macos-latest'
run: echo ${{ env.TRANSLATOR_TAG }}

# Debugging step to ensure tag is correct
- name: check env
if: matrix.os == 'windows-latest'
run: echo "${{ env.TRANSLATOR_TAG }}"

# Action to release build by given tag
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
- name: Build
run: cargo build --release --locked --package translator_sv2
run: cargo build --release --locked --manifest-path=roles/pool/Cargo.toml
- name: Upload binaries to release
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: target/release/${{ matrix.artifact_name }}
asset_name: ${{ matrix.asset_name }}
tag: ${{ env.TRANSLATOR_TAG }}

github_release_pool:
runs-on: ${{ matrix.os }}
strategy:
matrix:
# This defines what environments we will build on
include:
- os: ubuntu-latest
artifact_name: pool_sv2
asset_name: pool_sv2-linux-amd64
# - os: windows-latest
# artifact_name: pool_sv2.exe
# asset_name: pool_sv2-windows-amd64
- os: macos-latest
artifact_name: pool_sv2
asset_name: pool_sv2-macos-amd64


file: roles/target/release/pool_sv2
asset_name: pool_sv2
tag: ${{ github.ref }}
release_jdc:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

# The tags are not in scope until we fetch them from main
# This will fail if there are no tags available
- name: fetch tags
run: git fetch origin --tags

# Find the latest pool tag by listing folders in `.git/refs/tags` with pattern `pool_sv2`,
# taking the last one, and setting to `POOL_TAG` env variable. This will be used as the "tag" in the
# Build step
- name: set env unix
if: matrix.os == 'ubuntu-latest' || matrix.os == 'macos-latest'
run: echo "POOL_TAG=$(echo refs/tags/$(ls .git/refs/tags | grep 'pool_sv2' | tail -n 1))" >> $GITHUB_ENV

# This does not work
- name: set env windows
if: matrix.os == 'windows-latest'
run: echo "$(dir .git/refs/tags | findstr "pool_sv2")"

# This will fail on a Windows build. Must use if statement to check if running on Windows and use `dir` instead)
# `dir` will fail on mac builds
- name: check refs
run: ls .git/refs/tags

# Debugging step to ensure tag is correct
- name: check env
if: matrix.os == 'ubuntu-latest' || matrix.os == 'macos-latest'
run: echo ${{ env.POOL_TAG }}

# Debugging step to ensure tag is correct
- name: check env
if: matrix.os == 'windows-latest'
run: echo "${{ env.POOL_TAG }}"

# Action to release build by given tag
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
- name: Build
run: cargo build --release --locked --package pool_sv2
run: cargo build --release --locked --manifest-path=roles/jd-client/Cargo.toml
- name: Upload binaries to release
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: target/release/${{ matrix.artifact_name }}
asset_name: ${{ matrix.asset_name }}
tag: ${{ env.POOL_TAG }}

github_release_mining_proxy:
runs-on: ${{ matrix.os }}
strategy:
matrix:
# This defines what environments we will build on
include:
- os: ubuntu-latest
artifact_name: mining_proxy_sv2
asset_name: mining_proxy_sv2-linux-amd64
# - os: windows-latest
# artifact_name: mining_proxy_sv2.exe
# asset_name: mining_proxy_sv2-windows-amd64
- os: macos-latest
artifact_name: mining_proxy_sv2
asset_name: mining_proxy_sv2-macos-amd64


file: roles/target/release/jd_client
asset_name: jd_client
tag: ${{ github.ref }}
release_jds:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

# The tags are not in scope until we fetch them from main
# This will fail if there are no tags available
- name: fetch tags
run: git fetch origin --tags

# Find the latest mining proxy tag by listing folders in `.git/refs/tags` with pattern `mining_proxy_sv2`,
# taking the last one, and setting to `MINING_PROXY_TAG` env variable. This will be used as the "tag" in the
# Build step
- name: set env unix
if: matrix.os == 'ubuntu-latest' || matrix.os == 'macos-latest'
run: echo "MINING_PROXY_TAG=$(echo refs/tags/$(ls .git/refs/tags | grep 'mining_proxy_sv2' | tail -n 1))" >> $GITHUB_ENV

# This does not work
- name: set env windows
if: matrix.os == 'windows-latest'
run: echo "$(dir .git/refs/tags | findstr "mining_proxy_sv2")"

# This will fail on a Windows build. Must use if statement to check if running on Windows and use `dir` instead)
# `dir` will fail on mac builds
- name: check refs
run: ls .git/refs/tags

# Debugging step to ensure tag is correct
- name: check env
if: matrix.os == 'ubuntu-latest' || matrix.os == 'macos-latest'
run: echo ${{ env.MINING_PROXY_TAG }}

# Debugging step to ensure tag is correct
- name: check env
if: matrix.os == 'windows-latest'
run: echo "${{ env.MINING_PROXY_TAG }}"

# Action to release build by given tag
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
- name: Build
run: cargo build --release --locked --package mining_proxy_sv2
run: cargo build --release --locked --manifest-path=roles/jd-server/Cargo.toml
- name: Upload binaries to release
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: target/release/${{ matrix.artifact_name }}
asset_name: ${{ matrix.asset_name }}
tag: ${{ env.MINING_PROXY_TAG }}

file: roles/target/release/jd_server
asset_name: jd_server
tag: ${{ github.ref }}
release_proxy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
- name: Build
run: cargo build --release --locked --manifest-path=roles/mining-proxy/Cargo.toml
- name: Upload binaries to release
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: roles/target/release/mining_proxy_sv2
asset_name: mining_proxy_sv2
tag: ${{ github.ref }}
release_translator:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
- name: Build
run: cargo build --release --locked --manifest-path=roles/translator/Cargo.toml
- name: Upload binaries to release
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: roles/target/release/translator_sv2
asset_name: translator_sv2
tag: ${{ github.ref }}

0 comments on commit aaa44be

Please sign in to comment.