Skip to content

Create fifty-humans-care.md #111

Create fifty-humans-care.md

Create fifty-humans-care.md #111

Workflow file for this run

name: Release packages
on:
workflow_dispatch:
inputs:
skip_changesets:
description: 'Skip NPM publish via changesets (packages still built, versioned, and pushed to GitHub Packages)'
type: boolean
default: false
skip_github_packages:
description: 'Skip publishing to GitHub Packages'
type: boolean
default: false
push:
branches:
- main
paths:
- "packages/*/CHANGELOG.md"
- ".changeset/*"
concurrency: ${{ github.workflow }}-${{ github.ref }}
env:
NPM_CONFIG_PROVENANCE: true
TURBO_TELEMETRY_DISABLED: 1
DO_NOT_TRACK: 1
jobs:
release:
if: github.repository == 'padosoft/ts-support'
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
id-token: write
packages: write
steps:
- uses: actions/checkout@v7
with:
fetch-depth: 0
- uses: ./.github/actions/ci-setup
- name: Create Release Pull Request or Publish to NPM
id: changesets
if: inputs.skip_changesets != true
uses: changesets/action@v1
with:
version: bun version-packages
publish: bun publish-packages
commit: "chore(release): version packages"
title: "chore(release): version packages"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Build and version packages
if: inputs.skip_changesets == true
run: bun run build && bun run version-packages
- name: Publish to GitHub Packages
id: publish_github
if: inputs.skip_github_packages != true && (steps.changesets.outputs.published == 'true' || inputs.skip_changesets == true)
env:
NPM_CONFIG_PROVENANCE: false
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
echo "//npm.pkg.github.com/:_authToken=${GITHUB_TOKEN}" >> .npmrc
if [ "${{ inputs.skip_changesets }}" = "true" ]; then
echo "Publishing all packages to GitHub Packages"
for dir in packages/*/; do
if [ -f "${dir}package.json" ]; then
pkg_name=$(jq -r '.name' "${dir}package.json")
echo "Publishing $pkg_name from $dir via bun pm pack..."
pushd "$dir" > /dev/null
tarball=$(bun pm pack 2>&1 | grep -Eo '[^[:space:]]+\.tgz' | tail -1 || true)
if [ -z "$tarball" ] || [ ! -f "$tarball" ]; then
echo "::warning::Failed to pack $pkg_name, continuing..."
else
npm publish "$tarball" --registry https://npm.pkg.github.com/ --access public \
|| echo "::warning::Failed to publish $pkg_name, continuing..."
rm -f -- "$tarball"
fi
popd > /dev/null
fi
done
else
published='${{ steps.changesets.outputs.publishedPackages }}'
echo "$published" | jq -r '.[].name' | while IFS= read -r pkg_name; do
for dir in packages/*/; do
if [ -f "${dir}package.json" ]; then
name=$(jq -r '.name' "${dir}package.json")
if [ "$name" = "$pkg_name" ]; then
echo "Publishing $pkg_name to GitHub Packages via bun pm pack..."
pushd "$dir" > /dev/null
tarball=$(bun pm pack 2>&1 | grep -Eo '[^[:space:]]+\.tgz' | tail -1 || true)
if [ -z "$tarball" ] || [ ! -f "$tarball" ]; then
echo "::warning::Failed to pack $pkg_name, continuing..."
else
npm publish "$tarball" --registry https://npm.pkg.github.com/ --access public \
|| echo "::warning::Failed to publish $pkg_name, continuing..."
rm -f -- "$tarball"
fi
popd > /dev/null
fi
fi
done
done
fi
- name: Publish release tags
if: steps.changesets.outputs.published == 'true' || steps.publish_github.conclusion == 'success'
run: git push --follow-tags --set-upstream origin HEAD