From 3df4049a1c8bb392a9225cec143e2cc6af15cec2 Mon Sep 17 00:00:00 2001 From: shiipou Date: Sat, 14 Sep 2024 10:59:15 +0200 Subject: [PATCH] ci: fix CI publish to cargo only when needed --- .github/workflows/build.yml | 46 +++++++++++++++++++++++++++++++------ 1 file changed, 39 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b1ed4ca..0601aa4 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -18,7 +18,7 @@ jobs: prerelease-branches: "^(rc|beta|alpha)$" build: needs: get-version - if: ${{ needs.get-version.outputs.will-release }} + if: ${{ needs.get-version.outputs.will-release == 'true' }} runs-on: ${{ matrix.runner }} timeout-minutes: 20 env: @@ -93,14 +93,9 @@ jobs: name: clone-${{ matrix.os }}-${{ matrix.arch }} path: ./clone-${{ matrix.os }}-${{ matrix.arch }}${{ matrix.file_extension }} - - name: Publish cargo - if: ${{ needs.get-version.outputs.will-release && matrix.os == 'linux' && matrix.arch == 'x86_64' }} - shell: bash - run: cargo publish -p clone-project-manager --allow-dirty --token "${{ secrets.CARGO_TOKEN }}" - release: needs: [ get-version, build ] - if: ${{ needs.get-version.outputs.will-release }} + if: ${{ needs.get-version.outputs.will-release == 'true' }} uses: shiipou/github-actions/.github/workflows/release.yml@main with: version: ${{ needs.get-version.outputs.version }} @@ -108,3 +103,40 @@ jobs: is-prerelease: ${{ needs.get-version.outputs.is-prerelease == 'true' }} download-artifacts: true assets: artifacts/**/* + + publish: + needs: [ get-version, build ] + if: ${{ needs.get-version.outputs.will-release == 'true' }} + runs-on: ubuntu-latest + env: + VERSION: ${{ needs.get-version.outputs.version }} + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Install rust + uses: actions-rs/toolchain@v1 + with: + toolchain: stable + profile: minimal + override: true + target: ${{ matrix.target }} + + - name: Install cargo-edit + uses: actions-rs/cargo@v1 + with: + command: install + args: cargo-edit + + - name: Set version + uses: actions-rs/cargo@v1 + with: + command: set-version + args: ${{ env.VERSION }} + + - name: Build target + uses: actions-rs/cargo@v1 + with: + command: publish + args: -p clone-project-manager --no-verify --allow-dirty --token "${{ secrets.CARGO_TOKEN }}" +