Skip to content

Commit

Permalink
ci(publish): test
Browse files Browse the repository at this point in the history
  • Loading branch information
kwkwc committed Apr 14, 2024
1 parent af8c018 commit aa4abf8
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 15 deletions.
68 changes: 53 additions & 15 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -1,26 +1,35 @@
name: publish

on:
release:
types: [published]
push:
branches: ["dev"]
workflow_dispatch:

env:
CARGO_TERM_COLOR: always

permissions:
contents: write

jobs:
build-and-push-image:

runs-on: ubuntu-latest
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-musl
archive: tar.gz
- os: windows-latest
- build: linux
os: ubuntu-latest
target: x86_64-unknown-linux-gnu

- build: macos
os: macos-latest
target: x86_64-apple-darwin

- build: windows-gnu
os: windows-latest
target: x86_64-pc-windows-gnu
archive: zip

steps:
- uses: actions/checkout@v4
Expand All @@ -46,11 +55,40 @@ jobs:
run: |
make test
- name: Compile and release
uses: rust-build/rust-build.action@v1.4.5
env:
GITHUB_TOKEN: ${{ secrets.ASSETS_TOKEN }}
- name: Get the release version from the tag
shell: bash
run: |
echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
echo "version is: ${{ env.VERSION }}"
- name: Build
run: |
make build
- name: Build archive
shell: bash
run: |
# Replace with the name of your binary
binary_name="${{ github.event.repository.name }}"
dirname="$binary_name-${{ env.VERSION }}-${{ matrix.target }}"
mkdir "$dirname"
if [ "${{ matrix.os }}" = "windows-latest" ]; then
mv "target/${{ matrix.target }}/release/$binary_name.exe" "$dirname"
else
mv "target/${{ matrix.target }}/release/$binary_name" "$dirname"
fi
if [ "${{ matrix.os }}" = "windows-latest" ]; then
7z a "$dirname.zip" "$dirname"
echo "ASSET=$dirname.zip" >> $GITHUB_ENV
else
tar -czf "$dirname.tar.gz" "$dirname"
echo "ASSET=$dirname.tar.gz" >> $GITHUB_ENV
fi
- name: Upload the binaries
uses: softprops/action-gh-release@v2
with:
RUSTTARGET: ${{ matrix.target }}
ARCHIVE_TYPES: ${{ matrix.archive }}
STATIC_LINKING: false
files: |
${{ env.ASSET }}
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,7 @@ test:

.PHONY: check-all
check-all: format-check lint test

.PHONY: build
format:
cargo build --release --verbose

0 comments on commit aa4abf8

Please sign in to comment.