mirror of
https://github.com/encounter/objdiff.git
synced 2025-06-07 15:13:47 +00:00
ci: Auto cargo publish / npm publish
This commit is contained in:
parent
2bcbc34850
commit
fe886f862d
89
.github/workflows/build.yaml
vendored
89
.github/workflows/build.yaml
vendored
@ -72,7 +72,7 @@ jobs:
|
|||||||
name: Test
|
name: Test
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
platform: [ubuntu-latest, windows-latest, macos-latest]
|
platform: [ ubuntu-latest, windows-latest, macos-latest ]
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
runs-on: ${{ matrix.platform }}
|
runs-on: ${{ matrix.platform }}
|
||||||
steps:
|
steps:
|
||||||
@ -249,22 +249,30 @@ jobs:
|
|||||||
components: rust-src
|
components: rust-src
|
||||||
- name: Cache Rust workspace
|
- name: Cache Rust workspace
|
||||||
uses: Swatinem/rust-cache@v2
|
uses: Swatinem/rust-cache@v2
|
||||||
|
- name: Setup Node
|
||||||
|
uses: actions/setup-node@v4
|
||||||
|
with:
|
||||||
|
node-version: lts/*
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: npm -C objdiff-wasm install
|
run: npm -C objdiff-wasm ci
|
||||||
- name: Build
|
- name: Build
|
||||||
run: npm -C objdiff-wasm run build
|
run: npm -C objdiff-wasm run build
|
||||||
|
- name: Upload artifacts
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: wasm
|
||||||
|
path: objdiff-wasm/dist/
|
||||||
|
if-no-files-found: error
|
||||||
|
|
||||||
release:
|
check-version:
|
||||||
name: Release
|
name: Check package versions
|
||||||
if: startsWith(github.ref, 'refs/tags/')
|
if: startsWith(github.ref, 'refs/tags/')
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
needs: [build-cli, build-gui]
|
needs: [ build-cli, build-gui ]
|
||||||
permissions:
|
|
||||||
contents: write
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
- name: Check git tag against Cargo version
|
- name: Check git tag against package versions
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
set -eou pipefail
|
set -eou pipefail
|
||||||
@ -276,9 +284,24 @@ jobs:
|
|||||||
echo "::error::Git tag doesn't match the Cargo version! ($tag != $version)"
|
echo "::error::Git tag doesn't match the Cargo version! ($tag != $version)"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
version="v$(jq -r .version objdiff-wasm/package.json)"
|
||||||
|
if [ "$tag" != "$version" ]; then
|
||||||
|
echo "::error::Git tag doesn't match the npm version! ($tag != $version)"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
release-github:
|
||||||
|
name: Release (GitHub)
|
||||||
|
if: startsWith(github.ref, 'refs/tags/')
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
needs: [ check-version ]
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
steps:
|
||||||
- name: Download artifacts
|
- name: Download artifacts
|
||||||
uses: actions/download-artifact@v4
|
uses: actions/download-artifact@v4
|
||||||
with:
|
with:
|
||||||
|
pattern: objdiff-*
|
||||||
path: artifacts
|
path: artifacts
|
||||||
- name: Rename artifacts
|
- name: Rename artifacts
|
||||||
working-directory: artifacts
|
working-directory: artifacts
|
||||||
@ -308,3 +331,53 @@ jobs:
|
|||||||
files: out/*
|
files: out/*
|
||||||
draft: true
|
draft: true
|
||||||
generate_release_notes: true
|
generate_release_notes: true
|
||||||
|
|
||||||
|
release-cargo:
|
||||||
|
name: Release (Cargo)
|
||||||
|
if: startsWith(github.ref, 'refs/tags/')
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
needs: [ check-version ]
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
- name: Setup Rust toolchain
|
||||||
|
uses: dtolnay/rust-toolchain@stable
|
||||||
|
- name: Publish
|
||||||
|
env:
|
||||||
|
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
|
||||||
|
run: cargo publish -p objdiff-core --dry-run
|
||||||
|
|
||||||
|
release-npm:
|
||||||
|
name: Release (npm)
|
||||||
|
if: startsWith(github.ref, 'refs/tags/')
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
needs: [ check-version ]
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
- name: Setup Node
|
||||||
|
uses: actions/setup-node@v4
|
||||||
|
with:
|
||||||
|
node-version: lts/*
|
||||||
|
registry-url: 'https://registry.npmjs.org'
|
||||||
|
- name: Download artifacts
|
||||||
|
uses: actions/download-artifact@v4
|
||||||
|
with:
|
||||||
|
name: wasm
|
||||||
|
path: objdiff-wasm/dist
|
||||||
|
- name: Publish
|
||||||
|
working-directory: objdiff-wasm
|
||||||
|
env:
|
||||||
|
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||||
|
run: |
|
||||||
|
set -euo pipefail
|
||||||
|
version=$(jq -r '.version' package.json)
|
||||||
|
tag="latest"
|
||||||
|
# Check for prerelease by looking for a dash
|
||||||
|
case "$version" in
|
||||||
|
*-*)
|
||||||
|
tag=$(echo "$version" | sed -e 's/^[^-]*-//' -e 's/\..*$//')
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
echo "Publishing version $version with tag '$tag'..."
|
||||||
|
npm publish --provenance --access public --tag "$tag" --dry-run
|
||||||
|
Loading…
x
Reference in New Issue
Block a user