Version and Release #5
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Version and Release | |
on: | |
push: | |
branches: [main] | |
paths: | |
- '.changeset/**' | |
workflow_dispatch: | |
permissions: | |
contents: write | |
packages: write | |
issues: write | |
pull-requests: write | |
concurrency: ${{ github.workflow }}-${{ github.ref }} | |
jobs: | |
version-and-release: | |
name: Version and Release | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Setup Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
cache: 'npm' | |
- name: Install Dependencies | |
run: npm ci | |
- name: Build | |
run: npm run build | |
- name: Test | |
run: npm run test | |
- name: Create Version PR | |
id: changesets | |
uses: changesets/action@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Print Version Status | |
run: | | |
if [[ "${{ steps.changesets.outputs.hasChangesets }}" == "true" ]]; then | |
echo "✨ Version updates created" | |
shopt -s nullglob | |
for changeset in .changeset/*.md; do | |
if [ -f "$changeset" ]; then | |
awk '/^---$/{p=1;next}/^---$/{p=0}p' "$changeset" | |
fi | |
done | |
else | |
echo "No changes detected - skipping version updates" | |
fi | |
- name: Create Releases for Updated Packages | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
if: steps.changesets.outputs.hasChangesets == 'true' | |
run: | | |
shopt -s nullglob | |
for changeset in .changeset/*.md; do | |
if [ -f "$changeset" ]; then | |
while read -r package_line; do | |
if [[ $package_line == \"@api-client-sdk-streamline-sample/* ]]; then | |
name=$(echo "$package_line" | cut -d'"' -f2) | |
version=$(echo "$package_line" | awk '{print $2}') | |
echo "Creating release for $name v$version" | |
gh workflow run release-base.yml \ | |
-f package-name="$name" \ | |
-f version="$version" \ | |
-f type="api" | |
fi | |
done < <(awk '/^---$/{p=1;next}/^---$/{p=0}p' "$changeset" | grep -v '^---$') | |
fi | |
done |