Skip to content
This repository has been archived by the owner on Nov 25, 2024. It is now read-only.

gh actions: fix published package detection #33

gh actions: fix published package detection

gh actions: fix published package detection #33

Workflow file for this run

name: Rust
on:
push:
branches: [ "main" ]
env:
CARGO_TERM_COLOR: always
jobs:
build-and-push-image:
runs-on: ubuntu-latest
# permissions:
# contents: read
# packages: write
steps:
- uses: actions/checkout@v4
- uses: jetli/[email protected]
with:
# Optional version of wasm-pack to install(eg. 'v0.9.1', 'latest')
version: 'latest'
- uses: actions/setup-node@v3
with:
node-version: 16
registry-url: https://npm.pkg.github.com/
- name: Generate Cargo.lock
run: cargo update
- name: Retrieve pkg name
run: echo "PKG_NAME=$(cargo pkgid | sed 's/.*#\(.*\)@\(.*\)/\1/g')" >> $GITHUB_ENV
- name: Retrieve version
run: echo "PKG_VERSION=$(cargo pkgid | sed 's/.*@\(.*\)/\1/g')" >> $GITHUB_ENV
- name: Test npm view
run: npm view --registry https://npm.pkg.github.com @novorender/${{ env.PKG_NAME }}
- name: Retrieve last published version
if: always()
run: echo "PUBLISHED_VERSION=$(if npm view --registry https://npm.pkg.github.com @novorender/${{ env.PKG_NAME }} version 2> /dev/null; then echo ''; else echo '0.0.0'; fi)" >> $GITHUB_ENV
- name: Config registry
if: env.PKG_VERSION != env.PUBLISHED_VERSION
run: echo "@arturoc:registry=https://npm.pkg.github.com" >> ~/.npmrc
- name: Build
if: env.PKG_VERSION != env.PUBLISHED_VERSION
run: wasm-pack build --scope=novorender --target bundler
# - name: Package
# run: wasm-pack pack
# - name: Login
# run: wasm-pack login --scope=@novorender --auth-type=legacy --registry=https://npm.pkg.github.com
- name: Publish package
if: env.PKG_VERSION != env.PUBLISHED_VERSION
run: wasm-pack publish --access=public
# run: npm --userconfig ~/.npmrc --registry https://npm.pkg.github.com publish ./pkg --access public
env:
NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}
# - name: Archive package
# if: env.PKG_VERSION != env.PUBLISHED_VERSION
# uses: actions/upload-artifact@v3
# with:
# name: ${{ env.PKG_NAME }}-${{ env.PKG_VERSION }}-${{github.sha}}
# path: pkg/${{ env.PKG_NAME }}-${{ env.PKG_VERSION }}.tgz