Skip to content

feat(cli): expose vpr as a package bin (#1988) #431

feat(cli): expose vpr as a package bin (#1988)

feat(cli): expose vpr as a package bin (#1988) #431

Workflow file for this run

name: Release
on:
push:
branches: [main]
paths:
- 'packages/cli/package.json'
permissions: {}
env:
RELEASE_BUILD: 'true'
DEBUG: 'napi:*'
jobs:
check:
if: github.repository == 'voidzero-dev/vite-plus'
name: Check version
runs-on: ubuntu-latest
permissions:
contents: read
outputs:
version_changed: ${{ steps.version.outputs.changed }}
version: ${{ steps.version.outputs.version }}
steps:
- uses: taiki-e/checkout-action@7d1e50e93dc4fb3bba58f85018fadf77898aee8b # v1.4.2
- name: Check version changes
uses: EndBug/version-check@095362f3cd50f690c8fa0e6afeea81834bd8d320 # v3.0.0
id: version
with:
static-checking: localIsNew
file-url: https://unpkg.com/vite-plus@latest/package.json
file-name: packages/cli/package.json
build-rust:
name: Build bindings and binaries
needs: check
if: needs.check.outputs.version_changed == 'true'
permissions:
contents: read
uses: ./.github/workflows/reusable-release-build.yml
with:
version: ${{ needs.check.outputs.version }}
cache-key: release
request-approval:
runs-on: ubuntu-latest
needs: [check, build-rust]
if: needs.check.outputs.version_changed == 'true'
steps:
- uses: tsickert/discord-webhook@b217a69502f52803de774ded2b1ab7c282e99645 # v7.0.0
with:
webhook-url: ${{ secrets.DISCORD_RELEASES_WEBHOOK_URL }}
content: 'Requesting approval for vite-plus v${{ needs.check.outputs.version }}: ${{ github.server_url }}/${{ github.repository }}/actions/workflows/release.yml'
Release:
runs-on: ubuntu-latest
environment: release
needs: [check, build-rust, request-approval]
if: needs.check.outputs.version_changed == 'true'
permissions:
contents: write
packages: write
id-token: write # Required for OIDC
env:
VERSION: ${{ needs.check.outputs.version }}
steps:
- uses: taiki-e/checkout-action@7d1e50e93dc4fb3bba58f85018fadf77898aee8b # v1.4.2
- uses: ./.github/actions/clone
- uses: pnpm/action-setup@0ebf47130e4866e96fce0953f49152a61190b271 # v6.0.9
- uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
node-version-file: .node-version
package-manager-cache: false
registry-url: 'https://registry.npmjs.org'
- name: Install dependencies
run: pnpm install
- name: Download cli dist
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
path: packages/cli/dist
pattern: cli
merge-multiple: true
- name: Download cli docs
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
path: packages/cli/docs
pattern: cli-docs
merge-multiple: true
- name: Download cli binding
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
path: packages/cli/artifacts
pattern: vite-plus-native-*
- name: Download core dist
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
path: packages/core/dist
pattern: core
merge-multiple: true
- name: Download LICENSE files
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
path: packages
pattern: licenses
merge-multiple: true
- uses: ./.github/actions/download-rolldown-binaries
with:
github-token: ${{ github.token }}
target: x86_64-unknown-linux-gnu
upload: 'false'
- name: Download Rust CLI binaries
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
path: rust-cli-artifacts
pattern: vite-global-cli-*
- name: Download installer binaries (Windows)
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
path: installer-artifacts
pattern: vp-setup-*
- name: Prepare installer binaries for release
run: |
mkdir -p installer-release
for artifact_dir in installer-artifacts/vp-setup-*/; do
if [ -d "$artifact_dir" ]; then
dir_name=$(basename "$artifact_dir")
target_name=${dir_name#vp-setup-}
cp "$artifact_dir/vp-setup.exe" "installer-release/vp-setup-${target_name}.exe"
fi
done
echo "Installer binaries:"
ls -la installer-release/ || echo "No installer binaries found"
- name: Download release archives
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
path: binary-release
pattern: vp-release-archive-*
merge-multiple: true
- name: 'Setup npm'
run: npm install -g npm@latest
- name: Prepare and publish native addons
run: node ./packages/cli/publish-native-addons.ts --mode npm
- name: Publish
run: |
pnpm publish --filter=./packages/core --tag latest --access public --no-git-checks
pnpm publish --filter=./packages/cli --tag latest --access public --no-git-checks
- name: Create release body
env:
REPOSITORY: ${{ github.repository }}
COMMIT_SHA: ${{ github.sha }}
run: |
INSTALL_BASH="curl -fsSL https://vite.plus | bash"
INSTALL_PS1="irm https://vite.plus/ps1 | iex"
cat > ./RELEASE_BODY.md <<EOF
## vite-plus v${VERSION}
### Published Packages
- \`@voidzero-dev/vite-plus-core@${VERSION}\`
- \`vite-plus@${VERSION}\`
### Installation
**macOS/Linux:**
\`\`\`bash
${INSTALL_BASH}
\`\`\`
**Windows:**
\`\`\`powershell
${INSTALL_PS1}
\`\`\`
Or download and run \`vp-setup.exe\` from the assets below.
View the full commit: https://github.com/${REPOSITORY}/commit/${COMMIT_SHA}
EOF
- name: Create GitHub Release
uses: softprops/action-gh-release@718ea10b132b3b2eba29c1007bb80653f286566b # v3.0.1
id: release
with:
body_path: ./RELEASE_BODY.md
draft: true
make_latest: true
prerelease: false
name: vite-plus v${{ env.VERSION }}
tag_name: v${{ env.VERSION }}
target_commitish: ${{ github.sha }}
files: |
installer-release/vp-setup-*.exe
binary-release/vp-*.tar.gz
binary-release/vp-*.zip
- name: Publish GitHub Release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: gh release edit "v${VERSION}" --draft=false --repo "${{ github.repository }}"
# Build and push the official toolchain Docker image to GHCR after the npm
# release is published (the image installs vp from npm, so the version must
# exist first). See docker/Dockerfile and docs/guide/docker.md.
publish-docker:
name: Publish Docker image
runs-on: ubuntu-latest
needs: [check, Release]
if: needs.check.outputs.version_changed == 'true'
permissions:
contents: read
packages: write
env:
VERSION: ${{ needs.check.outputs.version }}
IMAGE: ghcr.io/voidzero-dev/vite-plus
steps:
- uses: taiki-e/checkout-action@7d1e50e93dc4fb3bba58f85018fadf77898aee8b # v1.4.2
- uses: docker/setup-qemu-action@06116385d9baf250c9f4dcb4858b16962ea869c3 # v4.1.0
- uses: docker/setup-buildx-action@d7f5e7f509e45cec5c76c4d5afdd7de93d0b3df5 # v4.1.0
- name: Log in to GHCR
uses: docker/login-action@650006c6eb7dba73a995cc03b0b2d7f5ca915bee # v4.2.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Docker metadata
id: meta
uses: docker/metadata-action@80c7e94dd9b9319bd5eb7a0e0fe9291e23a2a2e9 # v6.1.0
with:
images: ${{ env.IMAGE }}
flavor: latest=false
tags: |
type=semver,pattern={{version}},value=${{ env.VERSION }}
type=semver,pattern={{major}}.{{minor}},value=${{ env.VERSION }}
type=semver,pattern={{major}},value=${{ env.VERSION }}
type=raw,value=latest
- name: Build and push
uses: docker/build-push-action@f9f3042f7e2789586610d6e8b85c8f03e5195baf # v7.2.0
with:
context: docker
file: docker/Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
VP_VERSION=${{ env.VERSION }}
provenance: false
# Announce the release on Discord last, after the Docker images are published,
# so the message can include the GHCR image. Runs after the npm release
# (Release) and the images (publish-docker).
discord-notify:
name: Notify Discord
runs-on: ubuntu-latest
# publish-docker already needs Release, so depending on it orders this last.
needs: [check, publish-docker]
if: needs.check.outputs.version_changed == 'true'
env:
VERSION: ${{ needs.check.outputs.version }}
IMAGE: ghcr.io/voidzero-dev/vite-plus
steps:
# Non-blocking: a webhook failure must not mark the release run as failed
# (npm, GitHub release, and Docker images are already published).
- name: Send Discord notification
continue-on-error: true
uses: tsickert/discord-webhook@b217a69502f52803de774ded2b1ab7c282e99645 # v7.0.0
with:
webhook-url: ${{ secrets.DISCORD_RELEASES_WEBHOOK_URL }}
embed-title: vite-plus v${{ env.VERSION }}
embed-description: |
A new release is available!
**Published Packages:**
• @voidzero-dev/vite-plus-core@${{ env.VERSION }}
• vite-plus@${{ env.VERSION }}
**Docker (GHCR):**
• `docker pull ${{ env.IMAGE }}:${{ env.VERSION }}`
**Install:**
• macOS/Linux: `curl -fsSL https://vite.plus | bash`
• Windows: `irm https://vite.plus/ps1 | iex`
embed-url: https://github.com/${{ github.repository }}/releases/tag/v${{ env.VERSION }}