Skip to content

Commit

Permalink
fixing workflow3
Browse files Browse the repository at this point in the history
  • Loading branch information
cio-haneul committed Jul 11, 2024
1 parent 621802b commit 87e27d4
Showing 1 changed file with 61 additions and 83 deletions.
144 changes: 61 additions & 83 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@ on:
- 'v*'

jobs:
build-linux:
build:
runs-on: ubuntu-latest
strategy:
matrix:
target: [x86_64-unknown-linux-gnu, x86_64-apple-darwin, aarch64-apple-darwin, x86_64-pc-windows-gnu]
steps:
- name: Checkout
uses: actions/checkout@v2
Expand All @@ -17,114 +20,89 @@ jobs:
with:
profile: minimal
toolchain: stable
target: x86_64-unknown-linux-gnu
target: ${{ matrix.target }}
override: true

- name: Install Dependencies
if: matrix.target == 'x86_64-pc-windows-gnu'
run: sudo apt-get install -y mingw-w64

- name: Build
run: cargo build --release --target x86_64-unknown-linux-gnu
run: cargo build --release --target ${{ matrix.target }}

- name: Package
run: tar -czvf which-allowed-linux.tar.gz -C target/x86_64-unknown-linux-gnu/release which-allowed
env:
package_name: which-allowed-linux.tar.gz

- name: Upload Release Asset
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: which-allowed-linux.tar.gz
asset_name: which-allowed-linux.tar.gz
asset_content_type: application/zip

build-macos-x86_64:
runs-on: macos-latest
run: |
if [ ${{ matrix.target }} == "x86_64-unknown-linux-gnu" ]; then
tar -czvf which-allowed-linux.tar.gz -C target/${{ matrix.target }}/release which-allowed;
echo "package_name=which-allowed-linux.tar.gz" >> $GITHUB_ENV;
elif [ ${{ matrix.target }} == "x86_64-apple-darwin" ]; then
tar -czvf which-allowed-macos-x86_64.tar.gz -C target/${{ matrix.target }}/release which-allowed;
echo "package_name=which-allowed-macos-x86_64.tar.gz" >> $GITHUB_ENV;
elif [ ${{ matrix.target }} == "aarch64-apple-darwin" ]; then
tar -czvf which-allowed-macos-aarch64.tar.gz -C target/${{ matrix.target }}/release which-allowed;
echo "package_name=which-allowed-macos-aarch64.tar.gz" >> $GITHUB_ENV;
elif [ ${{ matrix.target }} == "x86_64-pc-windows-gnu" ]; then
zip which-allowed-windows.zip target/${{ matrix.target }}/release/which-allowed.exe;
echo "package_name=which-allowed-windows.zip" >> $GITHUB_ENV;
fi
create_release:
runs-on: ubuntu-latest
needs: build
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Install Rust
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
target: x86_64-apple-darwin
override: true

- name: Build
run: cargo build --release --target x86_64-apple-darwin
- name: Install GitHub CLI
run: sudo apt-get install gh

- name: Package
run: tar -czvf which-allowed-macos-x86_64.tar.gz -C target/x86_64-apple-darwin/release which-allowed
- name: Create Release
id: create_release
run: |
TAG_NAME=$(echo $GITHUB_REF | sed 's|refs/tags/||')
gh release create $TAG_NAME -t $TAG_NAME -n "Release $TAG_NAME"
env:
package_name: which-allowed-macos-x86_64.tar.gz
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Upload Release Asset
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: which-allowed-macos-x86_64.tar.gz
asset_name: which-allowed-macos-x86_64.tar.gz
asset_content_type: application/zip

build-macos-aarch64:
runs-on: macos-latest
upload_assets:
runs-on: ubuntu-latest
needs: [build, create_release]
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Install Rust
uses: actions-rs/toolchain@v1
- name: Upload Linux Asset
if: env.package_name == 'which-allowed-linux.tar.gz'
uses: actions/upload-release-asset@v1
with:
profile: minimal
toolchain: stable
target: aarch64-apple-darwin
override: true

- name: Build
run: cargo build --release --target aarch64-apple-darwin
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: which-allowed-linux.tar.gz
asset_name: which-allowed-linux.tar.gz
asset_content_type: application/gzip

- name: Package
run: tar -czvf which-allowed-macos-aarch64.tar.gz -C target/aarch64-apple-darwin/release which-allowed
env:
package_name: which-allowed-macos-aarch64.tar.gz
- name: Upload macOS x86_64 Asset
if: env.package_name == 'which-allowed-macos-x86_64.tar.gz'
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: which-allowed-macos-x86_64.tar.gz
asset_name: which-allowed-macos-x86_64.tar.gz
asset_content_type: application/gzip

- name: Upload Release Asset
- name: Upload macOS aarch64 Asset
if: env.package_name == 'which-allowed-macos-aarch64.tar.gz'
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ github.event.release.upload_url }}
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: which-allowed-macos-aarch64.tar.gz
asset_name: which-allowed-macos-aarch64.tar.gz
asset_content_type: application/zip

build-windows:
runs-on: windows-latest
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Install Rust
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
target: x86_64-pc-windows-gnu
override: true

- name: Install Dependencies
run: choco install mingw

- name: Build
run: cargo build --release --target x86_64-pc-windows-gnu

- name: Package
run: Compress-Archive -Path target\x86_64-pc-windows-gnu\release\which-allowed.exe -DestinationPath which-allowed-windows.zip
env:
package_name: which-allowed-windows.zip
asset_content_type: application/gzip

- name: Upload Release Asset
- name: Upload Windows Asset
if: env.package_name == 'which-allowed-windows.zip'
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ github.event.release.upload_url }}
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: which-allowed-windows.zip
asset_name: which-allowed-windows.zip
asset_content_type: application/zip

0 comments on commit 87e27d4

Please sign in to comment.