Skip to content

chore(deps): bump validator from 13.15.15 to 13.15.20 (#439) #60

chore(deps): bump validator from 13.15.15 to 13.15.20 (#439)

chore(deps): bump validator from 13.15.15 to 13.15.20 (#439) #60

name: Release Please
on:
push:
branches:
- main
permissions:
contents: write
pull-requests: write
jobs:
release-please:
runs-on: ubuntu-latest
steps:
- uses: googleapis/release-please-action@v4
id: release
with:
config-file: release-please-config.json
manifest-file: .release-please-manifest.json
# Checkout code if release was created
- uses: actions/checkout@v4
if: ${{ steps.release.outputs.release_created }}
# Setup Node.js for npm publishing
- uses: actions/setup-node@v4
if: ${{ steps.release.outputs.release_created }}
with:
node-version: 22
registry-url: 'https://registry.npmjs.org'
# Install dependencies
- run: npm ci
if: ${{ steps.release.outputs.release_created }}
# Build the project
- run: npm run build
if: ${{ steps.release.outputs.release_created }}
# Build reproducible release artifact
- name: Package release artifact
if: ${{ steps.release.outputs.release_created }}
env:
RELEASE_ARTIFACT_DIR: release-artifacts
run: node dist/scripts/create-release-artifact.js
# Upload tarball and checksum to GitHub release
- name: Upload release assets
if: ${{ steps.release.outputs.release_created }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
RELEASE_TAG: ${{ steps.release.outputs.tag_name }}
run: |
set -eu
tarball_path=$(find release-artifacts -maxdepth 1 -name 'webssh2-*.tar.gz' -print -quit)
if [ -z "$tarball_path" ]; then
echo 'tarball not found' >&2
exit 1
fi
checksum_path="${tarball_path}.sha256"
if [ ! -f "$checksum_path" ]; then
echo 'checksum file not found' >&2
exit 1
fi
gh release upload "$RELEASE_TAG" "$tarball_path" "$checksum_path" --clobber
# Publish to npm
- run: npm publish --access public
if: ${{ steps.release.outputs.release_created }}
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
- name: Dispatch downstream repository
if: ${{ steps.release.outputs.release_created }}
env:
DISPATCH_REPO: ${{ secrets.DOWNSTREAM_REPO }}
DOWNSTREAM_TOKEN: ${{ secrets.DOWNSTREAM_TOKEN }}
RELEASE_TAG: ${{ steps.release.outputs.tag_name }}
run: |
set -euo pipefail
if [ -z "${DOWNSTREAM_TOKEN:-}" ]; then
echo 'DOWNSTREAM_TOKEN secret is not configured' >&2
exit 1
fi
if [ -z "${DISPATCH_REPO:-}" ]; then
echo 'DISPATCH_REPO secret is not configured' >&2
exit 1
fi
payload=$(jq -n --arg version "${RELEASE_TAG}" \
'{event_type:"webssh2-release", client_payload:{version:$version}}')
response_file=$(mktemp)
error_file=$(mktemp)
http_code=''
curl_status=0
set +e
http_code=$(curl \
--silent \
--show-error \
--write-out '%{http_code}' \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${DOWNSTREAM_TOKEN}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/${DISPATCH_REPO}/dispatches \
-d "${payload}" \
-o "${response_file}" 2>"${error_file}")
curl_status=$?
set -e
response_body=$(cat "${response_file}")
rm -f "${response_file}"
if [ -s "${error_file}" ]; then
echo "Dispatch stderr:"
cat "${error_file}" >&2
fi
rm -f "${error_file}"
if [ "${curl_status}" -ne 0 ]; then
echo "Dispatch request failed with exit code ${curl_status}" >&2
exit "${curl_status}"
fi
if [ -z "${http_code}" ]; then
echo 'Dispatch request did not return an HTTP status code' >&2
exit 1
fi
if [ "${http_code}" -ge 300 ]; then
echo "Dispatch request returned HTTP ${http_code}" >&2
if [ -n "${response_body}" ]; then
echo "Response body: ${response_body}" >&2
fi
exit 1
fi
if [ -n "${response_body}" ]; then
echo "Dispatch response: ${response_body}"
fi
echo "Dispatched webssh2-release for tag ${RELEASE_TAG}"