Skip to content

Commit

Permalink
ci: do not rebuild pubclished version
Browse files Browse the repository at this point in the history
  • Loading branch information
MarioArnt committed Jan 17, 2024
1 parent e99286b commit b5a7223
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 16 deletions.
39 changes: 27 additions & 12 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,35 +75,50 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install node
uses: actions/setup-node@v3
with:
node-version: "20"
registry-url: "https://registry.npmjs.org"
- name: Check if already published
id: npm_check_bin
env:
TARGET_VERSION: ${{needs.need_publish.outputs.npm_target_version}}
BUILD_NAME: ${{ matrix.build.NAME }}
run: |
bin="robespierre"
node_os=$(echo "${BUILD_NAME}" | cut -d '-' -f1)
export node_os
node_arch=$(echo "${BUILD_NAME}" | cut -d '-' -f2)
export node_arch
if [ "${BUILD_OS}" = "windows-2022" ]; then
export node_pkg="${bin}-windows-${node_arch}"
else
export node_pkg="${bin}-${node_os}-${node_arch}"
fi
current=$(npm view ${node_pkg} --json | jq -r '.version')
[[ "$current" == "$TARGET_VERSION" ]] && echo "bump=false" >> "$GITHUB_OUTPUT" || echo "bump=true" >> "$GITHUB_OUTPUT"
- name: Install Rust toolchain
if: steps.npm_check.outputs.bump == 'true'
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ matrix.build.TOOLCHAIN }}
target: ${{ matrix.build.TARGET }}
override: true
- name: Lint
run: |
cd src
cargo fmt -- --check
cargo clippy -- -D warnings
- name: Test
if: steps.npm_check.outputs.bump == 'true'
run: |
cargo check
cargo test --all
- name: Build
if: steps.npm_check.outputs.bump == 'true'
uses: actions-rs/cargo@v1
with:
command: build
args: --release --locked --target ${{ matrix.build.TARGET }}
use-cross: ${{ matrix.build.OS == 'ubuntu-20.04' }} # use `cross` for Linux builds

- name: Install node
uses: actions/setup-node@v3
with:
node-version: "20"
registry-url: "https://registry.npmjs.org"

- name: Publish to NPM
if: steps.npm_check.outputs.bump == 'true'
shell: bash
run: sh ./package.sh --publish
env:
Expand Down
4 changes: 0 additions & 4 deletions package.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
cd npm
# check if already published
manifest=$(jq -r '.version' ./npm/robespierre/package.json)
npm=$(npm view robespierre --json | jq -r '.version')
[[ "$manifest" == "$npm" ]] && exit 0 || echo "publishing new version"
# set the binary name
bin="robespierre"
# derive the OS and architecture from the build matrix name
Expand Down

0 comments on commit b5a7223

Please sign in to comment.