Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch to GitHub Action to handle changelog #47

Merged
merged 14 commits into from
Jul 9, 2024
7 changes: 5 additions & 2 deletions .all-contributorsrc
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@
"avatar_url": "https://avatars.githubusercontent.com/u/364319?v=4",
"profile": "https://clementbiron.com/",
"contributions": [
"data"
"data",
"review"
]
},
{
Expand Down Expand Up @@ -57,7 +58,9 @@
"profile": "https://mattischneider.fr/",
"contributions": [
"data",
"doc"
"doc",
"code",
"review"
]
},
{
Expand Down
25 changes: 15 additions & 10 deletions .github/workflows/changelog.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,23 @@
name: Check changelog
name: Changelog

on:
push:
branches-ignore:
- main
- push-action/** # Temporary branches created by CasperWA/push-protected@v2 action on release workflow
pull_request:
types: [ opened, reopened ]
workflow_call:
outputs:
release_type:
release-type:
description: The release type extracted from changelog
value: ${{ jobs.check_changelog.outputs.release_type }}
value: ${{ jobs.validate-changelog.outputs.release-type }}

jobs:
check_changelog:
uses: OpenTermsArchive/engine/.github/workflows/changelog.yml@main
validate-changelog:
runs-on: [ ubuntu-latest ]
outputs:
release-type: ${{ steps.validate-changelog.outputs.release-type }}
steps:
- uses: actions/checkout@v4

- name: Validate changelog
id: validate-changelog
uses: OpenTermsArchive/changelog-action/[email protected]
with:
funders: true
83 changes: 29 additions & 54 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,78 +1,53 @@
name: Release

on:
pull_request:
branches:
- main
types: [ closed ]

push:
branches: [ main ]

jobs:
changelog:
uses: ./.github/workflows/changelog.yml

test:
uses: ./.github/workflows/test.yml

release:
if: github.event.pull_request.merged == true
needs: [ changelog, test ]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
token: ${{ secrets.RELEASE_BOT_GITHUB_TOKEN }}
uses: actions/checkout@v4

- name: Configure Git author
run: |
git config --global user.name "Open Terms Archive Release Bot"
git config --global user.email "[email protected]"
- name: Update changelog
id: update-changelog
uses: OpenTermsArchive/changelog-action/[email protected]

- name: Bump package version
run: |
echo "Release type obtained from the previous job: '${{ needs.changelog.outputs.release_type }}'"
echo "NEW_VERSION=$(npm --no-git-tag-version version ${{ needs.changelog.outputs.release_type }})" >> $GITHUB_ENV

- name: Update changelog unreleased section with new version
uses: superfaceai/release-changelog-action@v2
with:
version: ${{ env.NEW_VERSION }}
operation: release
format: markdownlint
- name: Update package version
run: npm --no-git-tag-version --allow-same-version version ${{ steps.update-changelog.outputs.version }}

- name: Commit CHANGELOG.md and package.json changes and create tag
- name: Update repository
run: |
git add "package.json"
git add "package-lock.json"
git add "CHANGELOG.md"
git commit -m "Release ${{ env.NEW_VERSION }}"
git tag ${{ env.NEW_VERSION }}
git config user.name "Open Terms Archive Release Bot"
git config user.email "[email protected]"
git commit --message="Update changelog" CHANGELOG.md package.json package-lock.json
git push origin

- name: Run status checks for release commit on temporary branch # Use temporary branch to enable pushing commits to this branch protected by required status checks
uses: CasperWA/push-protected@v2
with:
token: ${{ secrets.RELEASE_BOT_GITHUB_TOKEN }}
branch: main
unprotect_reviews: true

- name: Push changes to repository
run: git push origin && git push --tags
- name: Tag commit
if: needs.changelog.outputs.release-type != 'no-release'
run: |
git tag v${{ steps.update-changelog.outputs.version }}
git push origin --tags

- name: Read version changelog
uses: superfaceai/release-changelog-action@v2
id: get-changelog
- name: Publish to NPM public repository
if: needs.changelog.outputs.release-type != 'no-release'
uses: JS-DevTools/npm-publish@v3
with:
version: ${{ env.NEW_VERSION }}
operation: read
token: ${{ secrets.NPMJS_ACCESS_TOKEN }}

- name: Create GitHub release
uses: softprops/action-gh-release@v1
if: needs.changelog.outputs.release-type != 'no-release'
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ env.NEW_VERSION }}
body: ${{ steps.get-changelog.outputs.changelog }}
token: ${{ secrets.RELEASE_BOT_GITHUB_TOKEN }}

- name: Publish to NPM public repository
uses: JS-DevTools/npm-publish@v1
with:
token: ${{ secrets.NPMJS_ACCESS_TOKEN }}
access: public
tag_name: v${{ steps.update-changelog.outputs.version }}
body: ${{ steps.update-changelog.outputs.content }}
token: ${{ secrets.GITHUB_TOKEN }}
10 changes: 7 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ name: Validate document types

on:
push:
branches-ignore: [ main ] # will be called from workflow call
pull_request:
types: [ opened, reopened ]
workflow_call:
Expand All @@ -10,7 +11,10 @@ jobs:
validate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
- run: npm install
- uses: actions/checkout@v4

- uses: actions/setup-node@v4

- run: npm ci

- run: npm test
6 changes: 6 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
CONTRIBUTING.md
CODE_OF_CONDUCT.md
.all-contributors*
.eslintrc.yml
.github/*
test/*
12 changes: 9 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
# Changelog

All notable changes to this project will be documented in this file.
All changes that impact users of this module are documented in this file, in the [Common Changelog](https://common-changelog.org) format with some additional specifications defined in the [CONTRIBUTING](./CONTRIBUTING.md) file. This codebase adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html) and the format is based on [Common Changelog](https://common-changelog.org).\
Unlike Common Changelog, the `unreleased` section of [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) is preserved with the addition of a tag to specify which type of release should be published and to foster discussions about it inside pull requests. This tag should be one of the names mandated by SemVer, within brackets: `[patch]`, `[minor]` or `[major]`. For example: `## Unreleased [minor]`.
## Unreleased [patch]

> Development of this release was supported by the [NGI0 Entrust Fund](https://nlnet.nl/entrust), a fund established by [NLnet](https://nlnet.nl/) with financial support from the European Commission's [Next Generation Internet](https://www.ngi.eu) programme, under the aegis of DG CNECT under grant agreement N°101069594. [Learn more](https://nlnet.nl/project/TOSDR-OTA/) on the NLNet website.

### Changed

- Use [@OpenTermsArchive/changelog-action](https://github.com/OpenTermsArchive/changelog-action/) in CI/CD
- Decrease package size to half

## 1.1.0 - 2023-10-25

Expand Down
33 changes: 32 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,41 @@ The addition process is thus designed to add significant friction to the additio

The process itself, while progressively formalised, still provides ample arbitrary control to the Core Team, in order to avoid loopholes that could lead to mass additions. As the process is more regularly used, this power will be progressively reduced to make the community more autonomous.

## List a new contributor in the Open Terms Archive website
## Contributors list

We acknowledge the efforts of our contributors by listing them on our [website](https://opentermsarchive.org) and this is made possible by the use of the [All Contributors bot](https://allcontributors.org/docs/en/bot/overview).

All Contributors enables adding a contributor with a comment on an issue or pull request, without writing code. To do this, please use the [dedicated issue](https://github.com/OpenTermsArchive/terms-types/issues/31) on this repository.

Please read the following [contributing guide](https://github.com/OpenTermsArchive/opentermsarchive.org/blob/main/CONTRIBUTING.md#list-a-new-contributor-in-the-open-terms-archive-website).

## Changelog

When opening a pull request, it is required to fill in the changelog. It must be determined whether the changes made to the codebase impact users or not. These two cases are mutually exclusive and have different implications.

### Modified terms types or data structure

All changes to the codebase that impact users must be documented in the [`CHANGELOG.md`](./CHANGELOG.md) file, following the [Common Changelog](https://common-changelog.org) format with these additional specifications:

1. The `unreleased` section of [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) must be added in the changelog with the addition of a tag to specify which type of release should be published and to foster discussions about it inside pull requests. This tag should be one of the names mandated by SemVer, within brackets: `[patch]`, `[minor]` or `[major]`. For example: `## Unreleased [minor]`.<br>
Changes that require an adjustment in the infrastructure, they are considered as a breaking change in order to notify Collection operators about the need to update their [deployment](https://github.com/OpenTermsArchive/deployment/blob/main/CHANGELOG.md) dependency accordingly.

2. Each listed change must provide an actionable way to adapt the user’s codebase, either directly in the changelog or through instructions or links.

3. Changes should be a single sentence without punctuation, following Common Changelog examples.

4. Since each release is produced automatically from a single pull request, the [notice](https://common-changelog.org/#23-notice) links to the source pull request rather than [references](https://common-changelog.org/#242-references), which would always reference the same pull request. References can link to relevant parts of an RFC, decision record, or diff. **This notice is automatically generated by the CI during the release process and should not be added manually.**

5. The [notice](https://common-changelog.org/#23-notice) is also used to present sponsor information and it is required. Since the development of this project is funded by different actors, and following discussions with sponsors, financial contributions are acknowledged in the changelog itself. The format of the notice thus diverges from the Common Changelog specification in that it is not “a single-sentence paragraph”. Sponsor information is in quote format, starts with “Development of this release was supported by <funding_from>”, and provides the name and link to the sponsor, as well as information on the specific funding instrument, as specified by the sponsor itself or as required by law. A short message from the sponsor might also be added, as long as it abides by the community’s [Code of Conduct](./CODE_OF_CONDUCT.md) and aligns with the project’s goals. For volunteer contributions, the sentence should start with: “Development of this release was made on a volunteer basis by <contributor_name>”

### Changes that do not impact users

For non-functional changes (e.g., documentation, CI workflows) that do not impact users and should not trigger a release, it must be clearly indicated that documenting these changes in the changelog is unnecessary by adding the following content in its entirety to the changelog:

```markdown
## Unreleased [no-release]

_Modifications made in this changeset do not add, remove or alter any behavior, dependency, API or functionality of the software. They only change non-functional parts of the repository, such as the README file or CI workflows._
```

This content will be automatically deleted by the CI after merging.