Skip to content

Commit

Permalink
ci: fix CI publish to cargo only when needed
Browse files Browse the repository at this point in the history
  • Loading branch information
shiipou committed Sep 14, 2024
1 parent aeb04f6 commit 3df4049
Showing 1 changed file with 39 additions and 7 deletions.
46 changes: 39 additions & 7 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -93,18 +93,50 @@ 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 }}
changelogs: ${{ needs.get-version.outputs.changelogs }}
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 }}"

0 comments on commit 3df4049

Please sign in to comment.