Skip to content

Commit

Permalink
feat: use rust-simple-release CI
Browse files Browse the repository at this point in the history
Signed-off-by: lxl66566 <[email protected]>
  • Loading branch information
lxl66566 committed Nov 20, 2024
1 parent 0a9797b commit ee6c674
Showing 1 changed file with 6 additions and 93 deletions.
99 changes: 6 additions & 93 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,106 +1,19 @@
name: Build/publish release

name: rust release action
on:
push:
tags:
- "v*"
workflow_dispatch:

jobs:
create-release:
if: (startsWith(github.ref_name, 'v') && github.ref_type == 'tag')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: taiki-e/create-gh-release-action@v1
with:
title: $version
token: ${{ secrets.GH_TOKEN }}

release:
name: Binary ${{ matrix.target }} (on ${{ matrix.os }})
continue-on-error: false
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
compress: true
- os: ubuntu-latest
target: aarch64-unknown-linux-gnu
compress: true
- os: ubuntu-latest
target: x86_64-unknown-linux-musl
compress: true
- os: ubuntu-latest
target: aarch64-unknown-linux-musl
compress: true
- os: windows-latest
compress: true
- os: macos-latest
target: x86_64-apple-darwin
compress: true
- os: macos-latest
target: aarch64-apple-darwin
compress: true
- os: ubuntu-latest
target: x86_64-unknown-freebsd
compress: true

# The type of runner that the job will run on
# Runs on Ubuntu if other os is not specified above
runs-on: ${{ matrix.os || 'ubuntu-latest' }}
timeout-minutes: 90
permissions:
contents: write

env:
SCCACHE_GHA_ENABLED: "true"
RUSTC_WRAPPER: "sccache"
os: [ubuntu-latest, windows-latest, macos-latest]
steps:
- uses: actions/checkout@v4

- name: create version file
if: (startsWith(github.ref_name, 'v') && github.ref_type == 'tag')
run: echo "${{github.ref_name}}" | tail -c+2 >> .build_version

- name: Get version from tag
id: extract_version
run: |
echo "version=${GITHUB_REF_NAME#v}" >> "$GITHUB_OUTPUT"
shell: bash

- name: Setup Rust toolchain
# uses: dtolnay/rust-toolchain@nightly
uses: actions-rs/toolchain@v1
with:
toolchain: nightly
override: true

- name: Run sccache-cache
uses: mozilla-actions/[email protected]

- run: sudo apt install musl-tools
if: startsWith(matrix.os, 'ubuntu')

- name: Install openssl on ubuntu if needed
if: startsWith(matrix.os, 'ubuntu')
run: grep -q 'openssl' 'Cargo.lock' && sudo apt install pkg-config libssl-dev || true
- name: Install openssl on macos if needed
if: startsWith(matrix.os, 'macos')
run: grep -q 'openssl' 'Cargo.lock' && brew install openssl || true
# - name: Set Perl environment variables
# if: runner.os == 'Windows'
# run: |
# # choco install openssl strawberryperl
# echo "PERL=$((where.exe perl)[0])" | Out-File -FilePath $env:GITHUB_ENV -Append -Encoding utf8
# echo "OPENSSL_SRC_PERL=$((where.exe perl)[0])" | Out-File -FilePath $env:GITHUB_ENV -Append -Encoding utf8

- name: Build and Upload
uses: taiki-e/upload-rust-binary-action@v1
- name: release rust project
uses: lxl66566/rust-simple-release@main
with:
bin: git-se
target: ${{ matrix.target }}
tar: unix
zip: windows
targets: aarch64-unknown-linux-gnu, aarch64-unknown-linux-musl, x86_64-pc-windows-msvc, x86_64-unknown-linux-musl, x86_64-unknown-linux-gnu, aarch64-apple-darwin, x86_64-apple-darwin
token: ${{ secrets.GH_TOKEN }}

0 comments on commit ee6c674

Please sign in to comment.