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

Replace local script by OpenTermsArchive/changelog-action #1091

Merged
merged 3 commits into from
Jun 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 5 additions & 47 deletions .github/workflows/changelog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,60 +5,18 @@ on:
workflow_dispatch:
workflow_call:
outputs:
release_type:
release-type:
description: The release type extracted from changelog
value: ${{ jobs.validate_changelog.outputs.release_type }}
no_functional_changes:
description: A boolean signaling that there are no functional changes in the changeset
value: ${{ jobs.check_functional_changes.outputs.no_functional_changes }}

value: ${{ jobs.validate_changelog.outputs.release-type }}

jobs:
check_functional_changes:
runs-on: [ ubuntu-latest ]
outputs:
no_functional_changes: ${{ steps.set_no_functional_changes.outputs.no_functional_changes }}
steps:
- uses: actions/checkout@v4

- name: Make release type available to subsequent jobs # For backwards compatibility, as this workflow is used in other Open Terms Archive repositories
run: |
if grep -q "## Unreleased \[no-release\]" CHANGELOG.md; then
echo "NO_FUNCTIONAL_CHANGES=true" >> $GITHUB_ENV
fi

- name: Print result
id: set_no_functional_changes
run: |
echo "no_functional_changes='${{ env.NO_FUNCTIONAL_CHANGES }}'"
echo "no_functional_changes=${{ env.NO_FUNCTIONAL_CHANGES }}" >> $GITHUB_OUTPUT


validate_changelog:
if: ${{ needs.check_functional_changes.outputs.no_functional_changes != 'true' }}
needs: [ check_functional_changes ]
runs-on: [ ubuntu-latest ]
outputs:
release_type: ${{ steps.set_release_type_output.outputs.release_type }}
release-type: ${{ steps.validate-changelog.outputs.release-type }}
steps:
- uses: actions/checkout@v4

- name: Install dependencies
run: npm ci

- name: Print no release assessment result
run: |
echo "Should this run NOT trigger any release: '${{ needs.check_functional_changes.outputs.no_release }}'"

- name: Validate changelog
run: npm run changelog --silent -- --validate

- name: Get release type in changelog
run: echo "RELEASE_TYPE=$(npm run changelog --silent -- --get-release-type)" >> $GITHUB_ENV

- name: Make release type available to subsequent jobs # For backwards compatibility, as this workflow is used in other Open Terms Archive repositories
if: env.RELEASE_TYPE
id: set_release_type_output
run: |
echo "Found release type '${{ env.RELEASE_TYPE }}'"
echo "release_type=${{ env.RELEASE_TYPE }}" >> $GITHUB_OUTPUT
id: validate-changelog
uses: OpenTermsArchive/changelog-action/validate@v0.2.0
35 changes: 15 additions & 20 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,42 +9,38 @@ on:

jobs:
changelog:
uses: "OpenTermsArchive/engine/.github/workflows/changelog.yml@main"
uses: "./.github/workflows/changelog.yml"
test:
uses: "OpenTermsArchive/engine/.github/workflows/test.yml@main"
release:
if: github.event.pull_request.merged == true && needs.changelog.outputs.no_functional_changes != 'true'
needs: [ changelog, test ]
if: needs.changelog.outputs.release-type != 'no-release'
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
token: ${{ secrets.RELEASE_BOT_GITHUB_TOKEN }}

- name: Install dependencies
run: npm ci

- name: Configure Git author
run: |
git config --global user.name "Open Terms Archive Release Bot"
git config --global user.email "release-bot@opentermsarchive.org"

- name: Bump package version
run: |
echo "Release type found: '$(npm run changelog --silent -- --get-release-type)'"
echo "NEW_VERSION=$(npm --no-git-tag-version version $(npm run changelog --silent -- --get-release-type))" >> $GITHUB_ENV
- name: Update changelog for release
id: release-changelog
uses: OpenTermsArchive/changelog-action/release@v0.2.0

- name: Update changelog unreleased section with new version
run: npm run changelog --silent -- --release ${{ github.event.number }} # github.event.number refers to the pull request number
- name: Bump package version
run: npm --no-git-tag-version version ${{ steps.release-changelog.outputs.version }}

- name: Commit CHANGELOG.md and package.json changes and create tag
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 commit -m "Release v${{ steps.release-changelog.outputs.version }}"
git tag v${{ steps.release-changelog.outputs.version }}

- 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
Expand All @@ -66,7 +62,7 @@ jobs:
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ env.NEW_VERSION }}
body: ${{ env.VERSION_CHANGELOG }}
body: ${{ steps.release-changelog.outputs.content }}
token: ${{ secrets.RELEASE_BOT_GITHUB_TOKEN }}

- name: Publish to NPM public repository
Expand All @@ -83,24 +79,23 @@ jobs:
client-payload: '{"version": "${{ env.NEW_VERSION }}"}'

clean_changelog:
if: github.event.pull_request.merged == true && needs.changelog.outputs.no_functional_changes == 'true'
if: needs.changelog.outputs.release-type == 'no-release'
needs: [ changelog ]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
token: ${{ secrets.RELEASE_BOT_GITHUB_TOKEN }}

- name: Install dependencies
run: npm ci

- name: Configure Git author
run: |
git config --global user.name "Open Terms Archive Release Bot"
git config --global user.email "release-bot@opentermsarchive.org"

- name: Erase unreleased information from changelog
- name: Update changelog for release
uses: OpenTermsArchive/changelog-action/release@v0.2.0

- name: Save changelog
run: |
npm run changelog --silent -- --clean-unreleased
git commit -m "Clean changelog" CHANGELOG.md
git push origin
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

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 file. This codebase adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## 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._

## 2.2.1 - 2024-06-07

_Full changeset and discussions: [#1088](https://github.com/OpenTermsArchive/engine/pull/1088)._
Expand Down
95 changes: 0 additions & 95 deletions scripts/changelog/changelog.js

This file was deleted.

Loading
Loading