Skip to content

Commit

Permalink
CI build/upload fix
Browse files Browse the repository at this point in the history
  • Loading branch information
2dav committed Oct 21, 2023
1 parent 919cbd2 commit df5f472
Showing 1 changed file with 62 additions and 19 deletions.
81 changes: 62 additions & 19 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,30 +1,73 @@
name: Release

permissions:
contents: write

on:
push:
tags:
- v*.*
- "v*.*"

permissions:
contents: write

jobs:
create-release:
runs-on: ubuntu-latest
build-and-upload:
name: Build and upload
runs-on: ${{ matrix.os }}

strategy:
matrix:
# You can add more, for any target you'd like!
include:
- build: windows-gnu
os: windows-latest
target: x86_64-pc-windows-gnu

steps:
- uses: actions/checkout@v4
- uses: taiki-e/create-gh-release-action@v1
- name: Checkout
uses: actions/checkout@v4

- name: Get the release version from the tag
shell: bash
run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV

- name: Install Rust
# Or @nightly if you want
uses: dtolnay/rust-toolchain@stable
# Arguments to pass in
with:
token: ${{ secrets.GITHUB_TOKEN }}
# Make Rust compile to our target (defined in the matrix)
targets: ${{ matrix.target }}

upload-assets:
needs: create-release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: taiki-e/upload-rust-binary-action@v1
- name: Build
uses: actions-rs/cargo@v1
with:
use-cross: true
command: build
args: --verbose --release --target ${{ matrix.target }}

- name: Build archive
shell: bash
run: |
# Replace with the name of your binary
binary_name="<BINARY_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: Release
uses: softprops/action-gh-release@v1
with:
bin: txcproxy
target: x86_64-pc-windows-gnu
archive: $bin-$tag
token: ${{ secrets.GITHUB_TOKEN }}
files: |
${{ env.ASSET }}

0 comments on commit df5f472

Please sign in to comment.