Skip to content

Commit

Permalink
[DEVEX-89] Add Changeset (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
balanza authored Apr 12, 2024
1 parent b50135a commit c7c8222
Show file tree
Hide file tree
Showing 6 changed files with 2,601 additions and 116 deletions.
8 changes: 8 additions & 0 deletions .changeset/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Changesets

Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works
with multi-package repos, or single-package repos to help you version and publish your code. You can
find the full documentation for it [in our repository](https://github.com/changesets/changesets)

We have a quick list of common questions to get you started engaging with this project in
[our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md)
11 changes: 11 additions & 0 deletions .changeset/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"$schema": "https://unpkg.com/@changesets/[email protected]/schema.json",
"changelog": "@changesets/cli/changelog",
"commit": false,
"fixed": [],
"linked": [],
"access": "restricted",
"baseBranch": "main",
"updateInternalDependencies": "patch",
"ignore": []
}
73 changes: 73 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: Release

on:
push:
branches:
- main

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"

- name: Install Dependencies
run: yarn

- 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'
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: Checkout Repo
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Create release
uses: softprops/action-gh-release@v1
with:
draft: false
tag_name: ${{ matrix.package.name }}@${{ matrix.package.version }}
generate_release_notes: true
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,19 @@ Technical documentation about the project. Topics that may be included are archi

User documentation doesn't usually go in here. For public packages, it must go in the package's `README` file so that it will also be uploaded to the registry; user-faced documentation websites, when needed by the project, go under the `/apps` folder as they are treated as end-user applications.

## Releases

Releases are handled using [Changeset](https://github.com/changesets/changesets).
Changeset takes care of bumping packages, updating the changelog, and tag the repository accordingly.

#### How it works
* When opening a Pull Request with a change intended to be published, [add a changeset file](https://github.com/changesets/changesets/blob/main/docs/adding-a-changeset.md) to the proposed changes.
* Once the Pull Request is merged, a new Pull Request named `Version Packages` will be automatically opened with all the release changes such as version bumping for each involved app or package and changelog update; if an open `Version Packages` PR already exists, it will be updated and the package versions calculated accordingly (see https://github.com/changesets/changesets/blob/main/docs/decisions.md#how-changesets-are-combined).
Only apps and packages mentioned in the changeset files will be bumped.
* Review the `Version Packages` PR and merge it when ready. Changeset files will be deleted.
* A Release entry is created for each app or package whose version has been bumped.


## Infrastructure as Code

### Folder structure
Expand Down
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,12 @@
"build": "turbo build",
"test": "turbo test",
"lint": "turbo lint",
"format": "prettier --write \"**/*.{ts,tsx,md}\""
"format": "prettier --write \"**/*.{ts,tsx,md}\"",
"version": "changeset version",
"release": "changeset tag"
},
"devDependencies": {
"@changesets/cli": "^2.27.1",
"@pagopa/eslint-config-node": "*",
"@pagopa/typescript-config-node": "*",
"prettier": "^3.1.1",
Expand All @@ -24,4 +27,4 @@
"configs/*",
"tests/*"
]
}
}
Loading

0 comments on commit c7c8222

Please sign in to comment.