Skip to content

Commit

Permalink
Try copying Tarmac's release workflow instead
Browse files Browse the repository at this point in the history
  • Loading branch information
jackTabsCode committed Mar 6, 2024
1 parent 93579cf commit 1f8916f
Showing 1 changed file with 36 additions and 98 deletions.
134 changes: 36 additions & 98 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,119 +2,57 @@ name: Release

on:
push:
tags: ["v*"]
workflow_dispatch:
tags: ["*"]

jobs:
create-release:
name: Create Release
runs-on: ubuntu-latest
outputs:
upload_url: ${{ steps.create_release.outputs.upload_url }}
steps:
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: ${{ github.ref }}
draft: true
prerelease: false
windows:
runs-on: windows-latest

build:
needs: ["create-release"]
strategy:
fail-fast: false
matrix:
# https://doc.rust-lang.org/rustc/platform-support.html
include:
- host: linux
os: ubuntu-20.04
target: x86_64-unknown-linux-gnu
label: linux-x86_64
steps:
- uses: actions/checkout@v4

- host: windows
os: windows-latest
target: x86_64-pc-windows-msvc
label: windows-x86_64
- name: Build release binary
run: cargo build --verbose --locked --release

- host: macos
os: macos-latest
target: x86_64-apple-darwin
label: macos-x86_64
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: asphalt-win64
path: target/release/asphalt.exe

- host: macos
os: macos-latest
target: aarch64-apple-darwin
label: macos-aarch64
macos:
runs-on: macos-latest

name: Build (${{ matrix.target }})
runs-on: ${{ matrix.os }}
env:
BIN: asphalt
steps:
- uses: actions/checkout@v3
with:
submodules: true

- name: Get Version from Tag
shell: bash
# https://github.community/t/how-to-get-just-the-tag-name/16241/7#M1027
run: |
echo "PROJECT_VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_ENV
echo "Version is: ${{ env.PROJECT_VERSION }}"
- uses: actions/checkout@v4

- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
target: ${{ matrix.target }}
override: true
profile: minimal
run: curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y

- name: Setup Aftman
uses: ok-nick/setup-aftman@v0.1.0
with:
token: ${{ secrets.GITHUB_TOKEN }}
trust-check: false
version: "v0.2.6"
- name: Build release binary
run: |
source $HOME/.cargo/env
cargo build --verbose --locked --release
- name: Build Release
run: cargo build --release --locked --verbose --target ${{ matrix.target }}
env:
# Build into a known directory so we can find our build artifact more
# easily.
CARGO_TARGET_DIR: output
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: asphalt-macos
path: target/release/asphalt

- name: Create Release Archive
shell: bash
run: |
mkdir staging
linux:
runs-on: ubuntu-latest

if [ "${{ matrix.host }}" = "windows" ]; then
cp "output/${{ matrix.target }}/release/$BIN.exe" staging/
cd staging
7z a ../release.zip *
else
cp "output/${{ matrix.target }}/release/$BIN" staging/
cd staging
zip ../release.zip *
fi
steps:
- uses: actions/checkout@v4

- name: Upload Archive to Release
uses: actions/upload-release-asset@v1
- name: Build
run: cargo build --locked --verbose --release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.create-release.outputs.upload_url }}
asset_path: release.zip
asset_name: ${{ env.BIN }}-${{ env.PROJECT_VERSION }}-${{ matrix.label }}.zip
asset_content_type: application/octet-stream
OPENSSL_STATIC: 1

- name: Upload Archive to Artifacts
uses: actions/upload-artifact@v3
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: ${{ env.BIN }}-${{ env.PROJECT_VERSION }}-${{ matrix.label }}.zip
path: release.zip
name: asphalt-linux
path: target/release/asphalt

0 comments on commit 1f8916f

Please sign in to comment.