Просмотр исходного кода

ci: build release and upload artifacts

Yujia Qiao 4 лет назад
Родитель
Сommit
5a54483f23
1 измененных файлов с 28 добавлено и 2 удалено
  1. 28 2
      .github/workflows/rust.yml

+ 28 - 2
.github/workflows/rust.yml

@@ -11,8 +11,20 @@ env:
 
 
 jobs:
 jobs:
   build:
   build:
-
-    runs-on: ubuntu-latest
+    name: Build for ${{ matrix.os }}
+    runs-on: ${{ matrix.os }}
+    strategy:
+      matrix:
+        include:
+          - os: ubuntu-latest
+            artifact_name: rathole
+            asset_name: rathole-linux-amd64
+          - os: windows-latest
+            artifact_name: rathole.exe
+            asset_name: rathole-windows-amd64.exe
+          - os: macos-latest
+            artifact_name: rathole
+            asset_name: rathole-macos-amd64
 
 
     steps:
     steps:
     - uses: actions/checkout@v2
     - uses: actions/checkout@v2
@@ -32,3 +44,17 @@ jobs:
       run: cargo hack check --feature-powerset --no-dev-deps
       run: cargo hack check --feature-powerset --no-dev-deps
     - name: Run tests
     - name: Run tests
       run: cargo test --verbose
       run: cargo test --verbose
+    - name: Build release
+      run: cargo build --release
+    - uses: actions/upload-artifact@v2
+      with:
+        name: ${{ matrix.asset_name }}
+        path: target/release/${{ matrix.artifact_name }}
+    - name: Release
+      uses: svenstaro/upload-release-action@v2
+      if: startsWith(github.ref, 'refs/tags/')
+      with:
+        repo_token: ${{ secrets.GITHUB_TOKEN }}
+        file: target/release/${{ matrix.artifact_name }}
+        asset_name: ${{ matrix.asset_name }}
+        tag: ${{ github.ref }}