Skip to content

Commit e18d048

Browse files
authored
Update release workflow (#102)
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
1 parent 5bb934d commit e18d048

File tree

3 files changed

+81
-69
lines changed

3 files changed

+81
-69
lines changed

.github/workflows/release.yml

Lines changed: 0 additions & 40 deletions
This file was deleted.
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
name: Version/Release
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
workflow_dispatch: {}
8+
9+
concurrency: ${{ github.workflow }}-${{ github.ref }}
10+
11+
jobs:
12+
version:
13+
runs-on: ubuntu-latest
14+
outputs:
15+
published: ${{ steps.version.outputs.published }}
16+
focalVersion: ${{ steps.jq.outputs.output && fromJson(steps.jq.outputs.output).focal }}
17+
focalAtomVersion: ${{ steps.jq.outputs.output && fromJson(steps.jq.outputs.output).focalAtom }}
18+
steps:
19+
- uses: actions/checkout@v3
20+
- uses: actions/setup-node@v3
21+
with:
22+
node-version-file: '.nvmrc'
23+
- name: Install packages
24+
run: yarn install --frozen-lockfile
25+
- name: Create Release Pull Request or Version
26+
id: version
27+
uses: changesets/action@v1
28+
with:
29+
version: yarn changeset version
30+
publish: yarn changeset tag
31+
commit: Version packages
32+
title: Release packages
33+
createGithubReleases: true
34+
env:
35+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
36+
- if: ${{ steps.version.outputs.published == 'true' }}
37+
uses: edwardgeorge/jq-action@v1
38+
id: jq
39+
with:
40+
input: ${{ steps.version.outputs.publishedPackages }}
41+
script: |
42+
map({ key: .name, value: .version }) |
43+
from_entries |
44+
{
45+
focal: .["@grammarly/focal"],
46+
focalAtom: .["@grammarly/focal-atom"]
47+
}
48+
49+
publish:
50+
runs-on: ubuntu-latest
51+
needs: version
52+
if: ${{ needs.version.outputs.published == 'true' }}
53+
steps:
54+
- uses: actions/checkout@v3
55+
- uses: actions/setup-node@v3
56+
with:
57+
node-version-file: '.nvmrc'
58+
- name: Install packages
59+
run: yarn install --frozen-lockfile
60+
- name: Build
61+
run: yarn build
62+
- name: Test
63+
run: yarn test
64+
- name: Package
65+
run: yarn package
66+
- name: Upload @grammarly/focal binaries to release
67+
if: ${{ needs.version.outputs.focalVersion }}
68+
uses: svenstaro/upload-release-action@v2
69+
with:
70+
repo_token: ${{ secrets.GITHUB_TOKEN }}
71+
file: ./packages/focal/grammarly-focal-v${{ needs.version.outputs.focalVersion }}.tgz
72+
asset_name: grammarly-focal-v${{ needs.version.outputs.focalVersion }}.tgz
73+
tag: '@grammarly/focal@${{ needs.version.outputs.focalVersion }}'
74+
- name: Upload @grammarly/focal-atom binaries to release
75+
if: ${{ needs.version.outputs.focalAtomVersion }}
76+
uses: svenstaro/upload-release-action@v2
77+
with:
78+
repo_token: ${{ secrets.GITHUB_TOKEN }}
79+
file: ./packages/focal-atom/grammarly-focal-atom-v${{ needs.version.outputs.focalAtomVersion }}.tgz
80+
asset_name: grammarly-focal-atom-v${{ needs.version.outputs.focalAtomVersion }}.tgz
81+
tag: '@grammarly/focal-atom@${{ needs.version.outputs.focalAtomVersion }}'

.github/workflows/version.yml

Lines changed: 0 additions & 29 deletions
This file was deleted.

0 commit comments

Comments
 (0)