Skip to content

Commit 1115c5f

Browse files
authored
Fix changelog and release workflows (#97)
2 parents 0e00c94 + 228755d commit 1115c5f

4 files changed

Lines changed: 76 additions & 42 deletions

File tree

.github/workflows/changelog.yml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,15 @@ name: Changelog
22

33
on:
44
pull_request:
5-
push:
6-
branches: [ 'push-action/**' ] # enable testing required checks, see https://github.com/CasperWA/push-protected?tab=readme-ov-file#update-your-workflow
5+
workflow_dispatch:
76
workflow_call:
87
outputs:
98
release-type:
109
description: The release type extracted from changelog
11-
value: ${{ jobs.validate-changelog.outputs.release-type }}
10+
value: ${{ jobs.validate.outputs.release-type }}
1211

1312
jobs:
14-
validate-changelog:
15-
if: github.base_ref == 'main' || github.base_ref == 'test-main' # check that changelog has valid unreleased changes only in PRs that could trigger a release
13+
validate:
1614
runs-on: [ ubuntu-latest ]
1715
outputs:
1816
release-type: ${{ steps.validate-changelog.outputs.release-type }}

.github/workflows/release.yml

Lines changed: 65 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -2,63 +2,95 @@ name: Release
22

33
on:
44
pull_request_target:
5-
branches: [ main, test-main ]
5+
branches:
6+
- main
67
types: [ closed ]
78

9+
permissions:
10+
id-token: write # Required for OIDC. See https://docs.npmjs.com/trusted-publishers#step-2-configure-your-cicd-workflow
11+
contents: read
12+
813
jobs:
914
changelog:
10-
uses: ./.github/workflows/changelog.yml
11-
15+
uses: "./.github/workflows/changelog.yml"
1216
test:
1317
uses: ./.github/workflows/test.yml
14-
1518
release:
16-
if: github.event.pull_request.merged == true
1719
needs: [ changelog, test ]
20+
if: github.event.pull_request.merged == true && needs.changelog.outputs.release-type != 'no-release'
1821
runs-on: ubuntu-latest
1922
steps:
2023
- name: Checkout
2124
uses: actions/checkout@v4
25+
with:
26+
token: ${{ secrets.RELEASE_BOT_GITHUB_TOKEN }}
2227

23-
- name: Update changelog
24-
id: update-changelog
28+
- uses: actions/setup-node@v4
29+
with:
30+
node-version: '24'
31+
registry-url: 'https://registry.npmjs.org'
32+
33+
- name: Configure Git author
34+
run: |
35+
git config --global user.name "Open Terms Archive Release Bot"
36+
git config --global user.email "release-bot@opentermsarchive.org"
37+
38+
- name: Update changelog for release
39+
id: release-changelog
2540
uses: OpenTermsArchive/changelog-action/release@v0.4.0
2641

27-
- name: Update package version
28-
run: npm --no-git-tag-version --allow-same-version version ${{ steps.update-changelog.outputs.version }}
42+
- name: Bump package version
43+
run: npm --no-git-tag-version version ${{ steps.release-changelog.outputs.version }}
2944

30-
- name: Update repository
45+
- name: Commit CHANGELOG.md and package.json changes and create tag
3146
run: |
32-
git config user.name "Open Terms Archive Release Bot"
33-
git config user.email "release-bot@opentermsarchive.org"
34-
git commit --message="Update changelog" CHANGELOG.md package.json package-lock.json
47+
git add "package.json"
48+
git add "package-lock.json"
49+
git add "CHANGELOG.md"
50+
git commit -m "Release v${{ steps.release-changelog.outputs.version }}"
51+
git tag v${{ steps.release-changelog.outputs.version }}
3552
36-
- 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
37-
uses: CasperWA/push-protected@v2.16.0 # 2.16 minimum is required to benefit from updated defaults
53+
- 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
54+
uses: CasperWA/push-protected@v2
3855
with:
3956
token: ${{ secrets.RELEASE_BOT_GITHUB_TOKEN }}
40-
branch: ${{ github.base_ref }}
41-
interval: 10 # seconds between checks
42-
pre_sleep: 15
43-
fail_fast: true
57+
branch: main
58+
unprotect_reviews: true
4459

45-
- name: Publish Git tag
46-
if: needs.changelog.outputs.release-type != 'no-release'
47-
run: |
48-
git tag v${{ steps.update-changelog.outputs.version }}
49-
git push --tags
60+
- name: Update npm
61+
run: npm install -g npm@latest
5062

5163
- name: Publish to NPM public repository
52-
if: needs.changelog.outputs.release-type != 'no-release'
53-
uses: JS-DevTools/npm-publish@v3
54-
with:
55-
token: ${{ secrets.NPMJS_ACCESS_TOKEN }}
56-
dry-run: ${{ github.base_ref != 'main' }}
64+
run: npm publish --provenance
5765

58-
- name: Publish GitHub release
59-
if: needs.changelog.outputs.release-type != 'no-release'
66+
- name: Push changes to repository
67+
run: git push origin && git push --tags
68+
69+
- name: Create GitHub release
6070
uses: softprops/action-gh-release@v2
6171
with:
62-
tag_name: v${{ steps.update-changelog.outputs.version }}
63-
body: ${{ steps.update-changelog.outputs.content }}
72+
tag_name: v${{ steps.release-changelog.outputs.version }}
73+
body: ${{ steps.release-changelog.outputs.content }}
74+
token: ${{ secrets.RELEASE_BOT_GITHUB_TOKEN }}
75+
76+
clean_changelog:
77+
if: github.event.pull_request.merged == true && needs.changelog.outputs.release-type == 'no-release'
78+
needs: [ changelog ]
79+
runs-on: ubuntu-latest
80+
steps:
81+
- uses: actions/checkout@v4
82+
with:
6483
token: ${{ secrets.RELEASE_BOT_GITHUB_TOKEN }}
84+
85+
- name: Configure Git author
86+
run: |
87+
git config --global user.name "Open Terms Archive Release Bot"
88+
git config --global user.email "release-bot@opentermsarchive.org"
89+
90+
- name: Update changelog for release
91+
uses: OpenTermsArchive/changelog-action/release@v0.2.0
92+
93+
- name: Save changelog
94+
run: |
95+
git commit -m "Clean changelog" CHANGELOG.md
96+
git push origin

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
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).
44

5+
## Unreleased [no-release]
6+
7+
_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._
8+
59
## 2.2.0 - 2025-12-30
610

711
_Full changeset and discussions: [#96](https://github.com/OpenTermsArchive/terms-types/pull/96)._

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
{
22
"name": "@opentermsarchive/terms-types",
33
"version": "2.2.0",
4-
"description": "Database of types of terms of service (“agreement”, “policy”, “guidelines”…) under which a service is delivered",
5-
"homepage": "https://github.com/OpenTermsArchive/terms-document-types#readme",
4+
"description": "Ontology of terms and conditions document types (e.g., agreements, policies, guidelines) under which digital services are provided, designed to normalize naming variations and enable comparison of terms across services regardless of provider-specific labels.",
5+
"homepage": "https://github.com/OpenTermsArchive/terms-types#readme",
66
"bugs": {
7-
"url": "https://github.com/OpenTermsArchive/terms-document-types/issues"
7+
"url": "https://github.com/OpenTermsArchive/terms-types/issues"
88
},
99
"repository": {
1010
"type": "git",
11-
"url": "git+https://github.com/OpenTermsArchive/terms-document-types.git"
11+
"url": "git+https://github.com/OpenTermsArchive/terms-types.git"
1212
},
1313
"license": "EUPL-1.2",
1414
"author": "OpenTermsArchive",

0 commit comments

Comments
 (0)