Skip to content

NPM Release

NPM Release #14

Workflow file for this run

name: NPM Release
on:
workflow_dispatch:
workflow_run:
workflows:
- "new-release"
types:
- completed
jobs:
# publish-binaries:
# name: Publish binaries
# runs-on: ${{ matrix.OS }}
# strategy:
# fail-fast: false
# matrix:
# include:
# - NAME: linux-x64-musl
# OS: ubuntu-22.04
# TOOLCHAIN: stable
# TARGET: x86_64-unknown-linux-musl
# - NAME: linux-arm64-musl
# OS: ubuntu-22.04
# TOOLCHAIN: stable
# TARGET: aarch64-unknown-linux-musl
# - NAME: linux-arm-musleabihf
# OS: ubuntu-22.04
# TOOLCHAIN: stable
# TARGET: arm-unknown-linux-musleabihf
# - NAME: win32-x64-msvc
# OS: windows-2022
# TOOLCHAIN: stable
# TARGET: x86_64-pc-windows-msvc
# - NAME: win32-arm64-msvc
# OS: windows-2022
# TOOLCHAIN: stable
# TARGET: aarch64-pc-windows-msvc
# - NAME: darwin-x64
# OS: macos-14
# TOOLCHAIN: stable
# TARGET: x86_64-apple-darwin
# - NAME: darwin-arm64
# OS: macos-14
# TOOLCHAIN: stable
# TARGET: aarch64-apple-darwin
# steps:
# - name: Checkout repository
# uses: actions/checkout@v4
# - name: Find latest tag
# uses: oprypin/find-latest-tag@v1
# with:
# repository: gnpaone/rust-just
# releases-only: true
# id: latesttag
# - name: Download release artifact
# uses: robinraju/[email protected]
# with:
# tag: ${{ steps.latesttag.outputs.tag }}
# fileName: just-${{ steps.latesttag.outputs.tag }}-${{ matrix.TARGET }}.*
# out-file-path: './release'
# - name: Extract and Copy Binary
# shell: bash
# run: |
# mkdir -p ./target/${{ matrix.TARGET }}/release
# if [[ ${{ matrix.OS }} == 'windows-2022' ]]; then
# unzip ./release/just-${{ steps.latesttag.outputs.tag }}-${{ matrix.TARGET }}.zip -d ./target/${{ matrix.TARGET }}/release/
# else
# tar -xzf ./release/just-${{ steps.latesttag.outputs.tag }}-${{ matrix.TARGET }}.tar.gz -C ./target/${{ matrix.TARGET }}/release/
# fi
# - name: Install node
# uses: actions/setup-node@v4
# with:
# node-version: 18
# registry-url: "https://registry.npmjs.org"
# - name: Publish to NPM
# shell: bash
# run: |
# cd npm
# bin="just"
# node_os=$(echo "${{ matrix.NAME }}" | cut -d '-' -f1)
# export node_os
# node_arch=$(echo "${{ matrix.NAME }}" | cut -d '-' -f2)
# export node_arch
# export version="${{ steps.latesttag.outputs.tag }}"
# if [ "${{ matrix.OS }}" = "windows-2022" ]; then
# export node_pkg="rust-${bin}-windows-${node_arch}"
# else
# export node_pkg="rust-${bin}-${node_os}-${node_arch}"
# fi
# mkdir -p "${node_pkg}/bin"
# envsubst < package.json.tmpl > "${node_pkg}/package.json"
# if [ "${{ matrix.OS }}" = "windows-2022" ]; then
# bin="${bin}.exe"
# fi
# cp "../target/${{ matrix.TARGET }}/release/${bin}" "${node_pkg}/bin"
# cp ./README.md "${node_pkg}"
# cd "${node_pkg}"
# npm publish
# env:
# NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
publish-base:
name: Publish the base package to NPM
# needs: publish-binaries
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Find latest tag
uses: oprypin/find-latest-tag@v1
with:
repository: gnpaone/rust-just
releases-only: true
id: latesttag
- name: Install node
uses: actions/setup-node@v4
with:
node-version: 18
registry-url: "https://registry.npmjs.org"
- name: Wait for npm repository to index the binaries
uses: AliSajid/[email protected]
with:
minimum: 30
maximum: 60
- name: Update version & lockfile
shell: bash
working-directory: npm/rust-just
run: |
LATEST_VERSION=${{ steps.latesttag.outputs.tag }}
sed -i "s/\"version\": \"[^\"]*\"/\"version\": \"$LATEST_VERSION\"/; s/\"\(rust-just-[^\"]*\)\": \"[^\"]*\"/\"\1\": \"$LATEST_VERSION\"/g" package.json
yarn install
env:
YARN_ENABLE_IMMUTABLE_INSTALLS: false
- name: Create PR
id: cpr
uses: peter-evans/create-pull-request@v7
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: "update version & modify lockfile"
committer: gnpaone <[email protected]>
author: gnpaone <[email protected]>
branch: npm-update
base: master
add-paths: |
npm/rust-just/package.json
npm/rust-just/yarn.lock
delete-branch: true
title: Bump npm package version
labels: ":mag_right: bump"
- name: Enable pull request automerge
if: steps.cpr.outputs.pull-request-operation == 'created'
uses: peter-evans/enable-pull-request-automerge@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
pull-request-number: ${{ steps.cpr.outputs.pull-request-number }}
- name: Delete PRs head branch
if: steps.cpr.outputs.pull-request-operation == 'created'
uses: dawidd6/action-delete-branch@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
numbers: ${{ steps.cpr.outputs.pull-request-number }}
- name: Ensure updated files are present
run: |
git fetch --all
git checkout master
git pull origin master
- name: Publish the package
shell: bash
working-directory: npm/rust-just
run: |
yarn config set npmAuthToken ${NODE_AUTH_TOKEN}
yarn config set npmPublishRegistry "https://registry.npmjs.org"
yarn build
cp ../README.md .
cp ../../CHANGELOG.md .
if [ ${{ contains(github.ref, '-') }} = "true" ]; then
yarn npm publish --tag rc
else
yarn npm publish
fi
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}