diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 22251f5..b06d9f7 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -2,7 +2,7 @@ name: Build and Release on: push: - branches: [ master ] + branches: [ master, release ] tags: - "v*" @@ -75,33 +75,39 @@ jobs: - name: Setup PostgreSQL uses: ikalnytskyi/action-setup-postgres@v6 - - id: build + - run: | + echo "HOST=$(rustc -vV | grep host: | awk '{print $2}')" >> $GITHUB_ENV + + - name: Build + if: ${{ env.HOST == matrix.target }} + uses: actions-rs/cargo@v1 + with: + command: build + args: --release + + - name: Build (cross-compile) + if: ${{ env.HOST != matrix.target }} run: | - export HOST=$(rustc -vV | grep host: | awk '{print $2}') - if [ "$HOST" = "$TARGET" ]; then - cargo build --release --target ${TARGET} - else - cargo install cross - cross build --release --target ${TARGET} - fi + cargo install cross + cross build --release --target ${{ matrix.target }} - pushd target/${TARGET}/release - if [[ "$TARGET" =~ "windows" ]]; then - 7z a $ASSET_NAME xsnippet-api.exe + - name: Upload artifacts + run: | + pushd target/${{ matrix.target }}/release + if [[ "${{ matrix.target }}" =~ "windows" ]]; then + 7z a ${{ matrix.name }} xsnippet-api.exe else - tar cvzf $ASSET_NAME xsnippet-api + tar cvzf ${{ matrix.name }} xsnippet-api fi - gh release upload $RELEASE_TAG $ASSET_NAME + gh release upload $RELEASE_TAG ${{ matrix.name }} popd - echo "asset_path=target/${TARGET}/release/$ASSET_NAME" >> $GITHUB_OUTPUT + echo "ASSET_PATH=target/${{ matrix.target }}/release/${{ matrix.name }}" >> $GITHUB_ENV env: - ASSET_NAME: ${{ matrix.name }} GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} GH_REPO: ${{ env.GITHUB_REPOSITORY }} - TARGET: ${{ matrix.target }} RELEASE_TAG: ${{ needs.create_release.outputs.release_tag }} - uses: actions/attest-build-provenance@v1 with: - subject-path: ${{ steps.build.outputs.asset_path }} + subject-path: ${{ env.ASSET_PATH }}