Skip to content

Version Packages (#39) #31

Version Packages (#39)

Version Packages (#39) #31

Workflow file for this run

name: Release
on:
push:
branches:
- main
- master
concurrency: ${{ github.workflow }}-${{ github.ref }}
jobs:
release:
name: Release
runs-on: ubuntu-latest
outputs:
published: ${{ steps.release.outputs.published }}
publishedPackages: ${{ steps.release.outputs.publishedPackages }}
steps:
- name: Checkout Repo
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup Node.js environment
uses: actions/setup-node@v3
with:
node-version-file: ".node-version"
cache: "yarn"
cache-dependency-path: |
yarn.lock
package.json
apps/**/package.json
packages/**/package.json
- name: Install dependencies
run: yarn install --immutable
- name: Create Release Pull Request or Tag
id: changesets
uses: changesets/action@v1
with:
version: yarn run version
publish: yarn run release
commit: "ci(changesets): version packages"
createGithubReleases: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Release output
id: release
run: |
# intermediate variable necessary to avoid quotes around the array
# that prevented the fromJson function to work correctly
publishedPackages=${{toJSON(steps.changesets.outputs.publishedPackages)}}
echo 'published=${{steps.changesets.outputs.published}}' >> "$GITHUB_OUTPUT"
echo "publishedPackages=$publishedPackages" >> "$GITHUB_OUTPUT"
publish:
name: Publish
needs: [release]
if: needs.release.outputs.published == 'true'
runs-on: ubuntu-latest
continue-on-error: true
strategy:
matrix:
package: ${{ fromJson(needs.release.outputs.publishedPackages) }}
steps:
- name: Check internal packages
# they are not supposed to be published
if: ${{ startsWith(matrix.package.name, '@') }}
run: |
echo '::error title=Internal::Package ${{ matrix.package.name }} is not supposed to be published'
exit 1
- name: Checkout Repo
uses: actions/checkout@v3
- name: Setup Node.js environment
uses: actions/setup-node@v3
with:
node-version-file: ".node-version"
cache: "yarn"
cache-dependency-path: |
yarn.lock
package.json
apps/**/package.json
packages/**/package.json
- name: Install dependencies
run: yarn
- name: Build
run: yarn build --filter ${{ matrix.package.name }}
- name: Package
run: yarn workspace ${{ matrix.package.name }} run build:package
- name: Create draft release
uses: softprops/action-gh-release@v1
with:
draft: true
files: apps/${{ matrix.package.name }}/${{ matrix.package.name }}-${{ matrix.package.version }}.zip
tag_name: ${{ matrix.package.name }}@${{ matrix.package.version }}
generate_release_notes: true