Skip to content

Commit

Permalink
try this
Browse files Browse the repository at this point in the history
  • Loading branch information
catoa committed Jan 3, 2025
1 parent 63f10bd commit 540ca8f
Showing 1 changed file with 91 additions and 92 deletions.
183 changes: 91 additions & 92 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,105 +14,104 @@ jobs:
- uses: actions-rust-lang/setup-rust-toolchain@v1
- run: cargo test

# build-and-release:
# runs-on: ${{ matrix.os }}
# strategy:
# matrix:
# os: [ubuntu-latest, macos-latest, windows-latest]
# needs: test
# steps:
# - name: Checkout code
# uses: actions/checkout@v4
#
# - name: Install Rust
# uses: actions-rs/toolchain@v1
# with:
# toolchain: stable
#
# - name: Build the project
# run: cargo build --release
#
# - name: Create GitHub Release
# uses: ncipollo/release-action@v1
# with:
# token: ${{ secrets.GITHUB_TOKEN }}
# tag_name: ${{ github.ref_name }}
# release_name: ${{ github.ref_name }}
# body: |
# This is a release for ${{ github.ref_name }}.
# See the changelog for details.
# draft: false
#
# - name: Upload Release Asset
# uses: actions/upload-release-asset@v1
# with:
# upload_url: ${{ steps.create_release.outputs.upload_url }}
# asset_path: target/${{matrix.os}}/release/checksum
# asset_name: checksum-${{ matrix.os }}
# asset_content_type: application/octet-stream
# on:
# push:
# branches:
# - main
#
# permissions:
# contents: write
#
# jobs:
build-and-release:
name: Build and upload
runs-on: ${{ matrix.os }}
needs: test
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
needs: test
include:
- build: linux
os: ubuntu-22.04
target: x86_64-unknown-linux-musl
- build: macos
os: macos-latest
target: x86_64-apple-darwin
- build: macos
os: macos-latest
target: aarch64-apple-darwin
# - build: windows-gnu
# os: windows-latest
# target: x86_64-pc-windows-gnu
steps:
- name: Checkout code
- name: Checkout
uses: actions/checkout@v4

- name: Get the release version from the tag
shell: bash
run: echo "VERSION=$(git describe --tags --always)" >> $GITHUB_ENV
- name: Install Rust
uses: actions-rs/toolchain@v1
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable

- name: Build the project
run: cargo build --release

- name: Create GitHub Release
if: ${{ matrix.os == 'ubuntu-latest' }}
uses: ncipollo/release-action@v1
targets: ${{ matrix.target }}
- name: Build
uses: actions-rs/cargo@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
tag_name: ${{ github.ref_name }}
release_name: ${{ github.ref_name }}
body: |
This is a release for ${{ github.ref_name }}.
See the changelog for details.
draft: false

- name: Upload Release Asset
uses: actions/upload-release-asset@v1
use-cross: true
command: build
args: --verbose --release --target ${{ matrix.target }}
- name: Build archive
shell: bash
if: startsWith(github.ref, 'refs/tags/')
run: |
binary_name="checksum"
dirname="$binary_name-${{ env.VERSION }}-${{ matrix.target }}"
mkdir "$dirname"
if [ "${{ matrix.os }}" = "windows-latest" ]; then
mv "target/${{ matrix.target }}/release/$binary_name.exe" "$dirname"
mv "target/${{ matrix.target }}/release/$binary_name" "$dirname"
if [ "${{ matrix.os }}" = "windows-latest" ]; then
7z a "$dirname.zip" "$dirname"
echo "ASSET=$dirname.zip" >> $GITHUB_ENV
tar -czf "$dirname.tar.gz" "$dirname"
echo "ASSET=$dirname.tar.gz" >> $GITHUB_ENV
- name: Release
uses: softprops/action-gh-release@v2
if: startsWith(github.ref, 'refs/tags/')
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: target/${{matrix.os}}/release/checksum
asset_name: checksum-${{ matrix.os }}
asset_content_type: application/octet-stream
# on:
# push:
# branches:
# - main
#
# permissions:
# contents: write
#
# jobs:
# build-and-release:
# name: Build and upload
# runs-on: ${{ matrix.os }}
# needs: test
# strategy:
# matrix:
# include:
# - build: linux
# os: ubuntu-22.04
# target: x86_64-unknown-linux-musl
# - build: macos
# os: macos-latest
# target: x86_64-apple-darwin
# - build: macos
# os: macos-latest
# target: aarch64-apple-darwin
# # - build: windows-gnu
# # os: windows-latest
# # target: x86_64-pc-windows-gnu
# steps:
# - name: Checkout
# uses: actions/checkout@v4
# - name: Get the release version from the tag
# shell: bash
# run: echo "VERSION=$(git describe --tags --always)" >> $GITHUB_ENV
# - name: Install Rust
# uses: dtolnay/rust-toolchain@stable
# with:
# targets: ${{ matrix.target }}
# - name: Build
# uses: actions-rs/cargo@v1
# with:
# use-cross: true
# command: build
# args: --verbose --release --target ${{ matrix.target }}
# - name: Build archive
# shell: bash
# if: startsWith(github.ref, 'refs/tags/')
# run: |
# binary_name="checksum"
# dirname="$binary_name-${{ env.VERSION }}-${{ matrix.target }}"
# mkdir "$dirname"
# if [ "${{ matrix.os }}" = "windows-latest" ]; then
# mv "target/${{ matrix.target }}/release/$binary_name.exe" "$dirname"
# mv "target/${{ matrix.target }}/release/$binary_name" "$dirname"
# if [ "${{ matrix.os }}" = "windows-latest" ]; then
# 7z a "$dirname.zip" "$dirname"
# echo "ASSET=$dirname.zip" >> $GITHUB_ENV
# tar -czf "$dirname.tar.gz" "$dirname"
# echo "ASSET=$dirname.tar.gz" >> $GITHUB_ENV
# - name: Release
# uses: softprops/action-gh-release@v2
# if: startsWith(github.ref, 'refs/tags/')
# with:
# files: |
# ${{ env.ASSET }}
files: |
${{ env.ASSET }}

0 comments on commit 540ca8f

Please sign in to comment.