Skip to content

Commit

Permalink
Update release workflow (#102)
Browse files Browse the repository at this point in the history
This PR merges the `release.yml` workflow with `version.yml` as
`version-and-release.yml`.

How it works:
- now the workflow is split into 2 jobs: `version` and `publish`
- `version` is responsible for
- creating/update release PR if needed when the change is not a new
version (has uncommitted changelog)
- version packages and create tags and GitHub releases when this is a
new version (committed changelog)
- after publishing by `changesets` action, the output contains versions
of the released packages
- this output is transformed by `jq` in a format to easily consume in
the next job
- `publish` does what `release.yml` used to do:
  - builds, tests, packs
  - uploads artifacts to the GitHub releases
  - now it uses tags for each package as these releases are now separate
  • Loading branch information
Igorbek authored Oct 23, 2023
1 parent 5bb934d commit e18d048
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 69 deletions.
40 changes: 0 additions & 40 deletions .github/workflows/release.yml

This file was deleted.

81 changes: 81 additions & 0 deletions .github/workflows/version-and-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
name: Version/Release

on:
push:
branches:
- master
workflow_dispatch: {}

concurrency: ${{ github.workflow }}-${{ github.ref }}

jobs:
version:
runs-on: ubuntu-latest
outputs:
published: ${{ steps.version.outputs.published }}
focalVersion: ${{ steps.jq.outputs.output && fromJson(steps.jq.outputs.output).focal }}
focalAtomVersion: ${{ steps.jq.outputs.output && fromJson(steps.jq.outputs.output).focalAtom }}
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
- name: Install packages
run: yarn install --frozen-lockfile
- name: Create Release Pull Request or Version
id: version
uses: changesets/action@v1
with:
version: yarn changeset version
publish: yarn changeset tag
commit: Version packages
title: Release packages
createGithubReleases: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- if: ${{ steps.version.outputs.published == 'true' }}
uses: edwardgeorge/jq-action@v1
id: jq
with:
input: ${{ steps.version.outputs.publishedPackages }}
script: |
map({ key: .name, value: .version }) |
from_entries |
{
focal: .["@grammarly/focal"],
focalAtom: .["@grammarly/focal-atom"]
}
publish:
runs-on: ubuntu-latest
needs: version
if: ${{ needs.version.outputs.published == 'true' }}
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
- name: Install packages
run: yarn install --frozen-lockfile
- name: Build
run: yarn build
- name: Test
run: yarn test
- name: Package
run: yarn package
- name: Upload @grammarly/focal binaries to release
if: ${{ needs.version.outputs.focalVersion }}
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: ./packages/focal/grammarly-focal-v${{ needs.version.outputs.focalVersion }}.tgz
asset_name: grammarly-focal-v${{ needs.version.outputs.focalVersion }}.tgz
tag: '@grammarly/focal@${{ needs.version.outputs.focalVersion }}'
- name: Upload @grammarly/focal-atom binaries to release
if: ${{ needs.version.outputs.focalAtomVersion }}
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: ./packages/focal-atom/grammarly-focal-atom-v${{ needs.version.outputs.focalAtomVersion }}.tgz
asset_name: grammarly-focal-atom-v${{ needs.version.outputs.focalAtomVersion }}.tgz
tag: '@grammarly/focal-atom@${{ needs.version.outputs.focalAtomVersion }}'
29 changes: 0 additions & 29 deletions .github/workflows/version.yml

This file was deleted.

0 comments on commit e18d048

Please sign in to comment.