Skip to content

Commit

Permalink
chore: リリースとビルドの自動化
Browse files Browse the repository at this point in the history
  • Loading branch information
0xNOY committed Apr 29, 2023
1 parent ff2fbca commit 4e4400f
Showing 1 changed file with 22 additions and 10 deletions.
32 changes: 22 additions & 10 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
- "v[0-9]+.[0-9]+.[0-9]+"

env:
APP_NAME: "tmgw_wifi_authorizer"
APP_NAME: "tmgw-wifi-authorizer"

jobs:
create-release:
Expand All @@ -24,7 +24,7 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: ${{ github.ref }}
release_name: ${{ github.ref_name }}
draft: false
prerelease: false

Expand All @@ -45,25 +45,37 @@ jobs:

runs-on: ${{ matrix.os }}

env:
APP_EXTENSION: ${{ contains(matrix.os, 'windows') && '.exe' || '' }}
CARGO_DST: ''
ZIP_DST: ''

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Set ENV
run: |
echo "CARGO_DST=target/${{ matrix.target }}/release/${{ env.APP_NAME }}${{ env.APP_EXTENSION }}" >> ${{ contains(matrix.os, 'windows') && '$env:GITHUB_ENV' || '$GITHUB_ENV' }}
echo "ZIP_DST=${{ env.APP_NAME }}-${{ matrix.target }}.zip" >> ${{ contains(matrix.os, 'windows') && '$env:GITHUB_ENV' || '$GITHUB_ENV' }}
- name: Build
run: cargo build --release --target ${{ matrix.target }}

- name: Archive
uses: actions/upload-artifact@v3
with:
name: ${{ env.APP_NAME }}_${{ matrix.target }}
path: target/${{ matrix.target }}/release/${{ env.APP_NAME }}
- name: Zip binary for Linux and MacOS
if: contains(matrix.os, 'ubuntu') || contains(matrix.os, 'macos')
run: zip -j ${{ env.ZIP_DST }} ${{ env.CARGO_DST }}

- name: Zip binary for Windows
if: contains(matrix.os, 'windows')
run: powershell Compress-Archive -Path ${{ env.CARGO_DST }} -DestinationPath ${{ env.ZIP_DST }}

- name: Upload to release
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.create-release.outputs.upload_url }}
asset_path: target/${{ matrix.target }}/release/${{ env.APP_NAME }}
asset_name: ${{ env.APP_NAME }}_${{ matrix.target }}
asset_content_type: application/octet-stream
asset_path: ${{ env.ZIP_DST }}
asset_name: ${{ env.ZIP_DST }}
asset_content_type: application/zip

0 comments on commit 4e4400f

Please sign in to comment.