Skip to content

chore: prepare release (#2867) #703

chore: prepare release (#2867)

chore: prepare release (#2867) #703

Workflow file for this run

name: Release
on:
push:
branches:
- main
jobs:
release:
# Prevents changesets action from creating a PR on forks
if: github.repository == 'patternfly/patternfly-elements'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '20'
cache: npm
- run: npm ci --prefer-offline
- run: npm run build
- run: npm run prepublishOnly --workspaces --if-present
- name: Create Release Pull Request or Publish to npm
id: changesets
uses: changesets/action@v1
with:
publish: npx changeset publish
commit: "chore: prepare release"
title: "chore: prepare release"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
# changesets action outputs `publishedPackages` in the format
# [{"name": "@xx/xx", "version": "1.2.0"}, {"name": "@xx/xy", "version": "0.8.9"}]
# The following step converts that list of objects to a list of strings (git tags for github releases)
# and joins them with commas, for consumption in the next step
# "@xx/[email protected], @xx/[email protected]"
- name: Transform Tags
id: get-tags
if: ${{ steps.changesets.outputs.published == 'true' }}
run: |
tags=$( echo '${{ steps.changesets.outputs.publishedPackages }}' | jq -c 'map([.name,.version]) | map(join("@")) | join(", ")' )
echo "$tags"
echo "::set-output name=tags::$tags"
- name: Bundle
id: bundle
if: ${{ steps.changesets.outputs.published == 'true' }}
uses: actions/github-script@v6
with:
debug: ${{ secrets.ACTIONS_RUNNER_DEBUG }}
github-token: ${{ secrets.WORKFLOWS_PAT }}
script: |
try {
const tags = ${{ steps.get-tags.outputs.tags }};
const result = await github.rest.actions.createWorkflowDispatch({
owner: 'patternfly',
repo: 'patternfly-elements',
workflow_id: 'bundle.yml',
ref: 'main',
inputs: {
tags
},
})
console.log(result);
} catch(error) {
console.error(error);
core.setFailed(error);
}