diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 6e24455..c5f60e1 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -1,6 +1,6 @@ on: [push, pull_request] -name: Build +name: Build & Release jobs: check: @@ -80,3 +80,74 @@ jobs: KVENV_CLIENT_SECRET: ${{ secrets.KVENV_CLIENT_SECRET }} KVENV_KEYVAULT_NAME: ${{ secrets.KVENV_KEYVAULT_NAME }} KVENV_SECRET_NAME: ${{ secrets.KVENV_SECRET_NAME }} + + release: + name: Create Github Release + if: contains(github.ref, 'tags/v') + needs: [check, fmt, clippy, test] + runs-on: ubuntu-latest + steps: + - name: Create Release + id: create_release + uses: actions/create-release@v1.0.0 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ github.ref }} + release_name: Release ${{ github.ref }} + draft: true + prerelease: false + - name: Output Release URL File + run: echo "${{ steps.create_release.outputs.upload_url }}" > release_url.txt + - name: Save Release URL File for publish + uses: actions/upload-artifact@v1 + with: + name: release_url + path: release_url.txt + + publish: + name: Upload binaries + if: contains(github.ref, 'tags/v') + needs: [check, fmt, clippy, test, release] + runs-on: ubuntu-latest + strategy: + matrix: + target: + - x86_64-unknown-linux-gnu + - x86_64-unknown-linux-musl + steps: + - uses: actions/checkout@v2 + - uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: stable + target: ${{ matrix.target }} + override: true + - uses: actions-rs/cargo@v1 + name: Build + with: + use-cross: ${{ matrix.target != 'x86_64-unknown-linux-gnu' }} + command: build + args: --release --target ${{ matrix.target }} + - name: Load Release URL File from release job + uses: actions/download-artifact@v1 + with: + name: release_url + - name: Get Release File Name & Upload URL + id: get_release_info + run: | + value=`cat release_url/release_url.txt` + echo ::set-output name=upload_url::$value + env: + TAG_REF_NAME: ${{ github.ref }} + REPOSITORY_NAME: ${{ github.repository }} + - name: Upload Release Asset + id: upload-release-asset + uses: actions/upload-release-asset@v1.0.1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.get_release_info.outputs.upload_url }} + asset_path: ./target/${{ matrix.target }}/release/kvenv + asset_name: kvenv-${{ matrix.target }} + asset_content_type: application/octet-stream diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml deleted file mode 100644 index 47dc2f2..0000000 --- a/.github/workflows/release.yaml +++ /dev/null @@ -1,58 +0,0 @@ -on: - push: - tags: - - 'v*' - -name: Release kvenv - -jobs: - build-and-release: - name: Build and release - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: stable - target: x86_64-unknown-linux-musl - override: true - - uses: actions-rs/cargo@v1 - name: "Build Glibc-based" - with: - command: build - args: --release - - uses: actions-rs/cargo@v1 - name: "Build static image" - with: - use-cross: true - command: build - args: --release --target x86_64-unknown-linux-musl - - name: Create Release - id: create_release - uses: actions/create-release@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - tag_name: ${{ github.ref }} - release_name: Release ${{ github.ref }} - draft: true - prerelease: false - - name: Upload x86_64-unknown-linux-gnu binary - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_path: ./target/release/kvenv - asset_name: kvenv-x86_64-unknown-linux-gnu - asset_content_type: application/octet-stream - - name: Upload x86_64-unknown-linux-musl (static) binary - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_path: ./target/x86_64-unknown-linux-musl/release/kvenv - asset_name: kvenv-x86_64-unknown-linux-musl - asset_content_type: application/octet-stream