Skip to content

Commit

Permalink
feat(semantic-release): adds last-release outputs
Browse files Browse the repository at this point in the history
This adds outputs for `last-release-version` & `last-release-major-version`.  This will allow us to
determine if a breaking change has occurred.
  • Loading branch information
greenkiwi committed Sep 14, 2023
1 parent 46ccef6 commit 11fe39f
Show file tree
Hide file tree
Showing 9 changed files with 57 additions and 9 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ jobs:
if: github.ref != 'refs/heads/main'
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: ./release-notes-preview
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/update-dependencies.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
if: false
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
- uses: ./
with:
github-token: ${{ secrets.OPEN_TURO_GITHUB_TOKEN }}
9 changes: 9 additions & 0 deletions .run/Template Jest.run.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<component name="ProjectRunConfigurationManager">
<configuration default="true" type="JavaScriptTestRunnerJest">
<node-interpreter value="project" />
<node-options value="--experimental-vm-modules" />
<envs />
<scope-kind value="ALL" />
<method v="2" />
</configuration>
</component>
15 changes: 11 additions & 4 deletions semantic-release/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,17 @@ jobs:

## Outputs

| parameter | description |
| --------------------- | -------------------------------------------- |
| new-release-published | Whether a new release was published |
| new-release-notes | The release notes for the new release if any |
| parameter | description |
| -------------------------- | ---------------------------------------------------------------------------------------------------------------- |
| new-release-published | Whether a new release was published |
| new-release-notes | The release notes for the new release if any |
| new-release-version | Version of the new release |
| new-release-major-version | Major version of the new release |
| new-release-minor-version | Minor version of the new release |
| new-release-patch-version | Patch version of the new release |
| new-release-type | Type of the new release: 'prerelease' \| 'prepatch' \| 'patch' \| 'preminor' \| 'minor' \| 'premajor' \| 'major' |
| last-release-version | Version of the last release |
| last-release-major-version | Major version of the last release |

## Runs

Expand Down
9 changes: 9 additions & 0 deletions semantic-release/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,15 @@ outputs:
new-release-patch-version:
description: "Patch version of the new release"
value: ${{ steps.semantic-release.outputs.new-release-patch-version }}
new-release-type:
description: "Type of the new release: 'prerelease' | 'prepatch' | 'patch' | 'preminor' | 'minor' | 'premajor' | 'major'"
value: ${{ steps.semantic-release.outputs.new-release-type }}
last-release-version:
description: "Version of the last release"
value: ${{ steps.semantic-release.outputs.last-release-version }}
last-release-major-version:
description: "Major version of the last release"
value: ${{ steps.semantic-release.outputs.last-release-major-version }}

runs:
using: composite
Expand Down
2 changes: 1 addition & 1 deletion semantic-release/dist/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion semantic-release/dist/index.js.map

Large diffs are not rendered by default.

11 changes: 10 additions & 1 deletion semantic-release/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,15 @@ const __dirname = path.dirname(__filename);

// enum with the outputs that the action has. this should be the same as action.yaml
const OUTPUTS = {
last_release_major_version: "last-release-major-version",
last_release_version: "last-release-version",
new_release_notes: "new-release-notes",
new_release_published: "new-release-published",
new_release_version: "new-release-version",
new_release_major_version: "new-release-major-version",
new_release_minor_version: "new-release-minor-version",
new_release_patch_version: "new-release-patch-version",
new_release_type: "new-release-type",
} as const;

interface Inputs {
Expand Down Expand Up @@ -120,9 +123,15 @@ export async function main() {
),
);
if (result) {
const { nextRelease } = result;
const { lastRelease, nextRelease } = result;
setOutput(OUTPUTS.last_release_version, lastRelease.version);
setOutput(
OUTPUTS.last_release_major_version,
semver.major(lastRelease.version),
);
if (nextRelease) {
setOutput(OUTPUTS.new_release_published, "true");
setOutput(OUTPUTS.new_release_type, nextRelease.type);
setOutput(OUTPUTS.new_release_notes, nextRelease.notes);
setOutput(OUTPUTS.new_release_version, nextRelease.version);
setOutput(
Expand Down
12 changes: 12 additions & 0 deletions semantic-release/test/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,22 @@ describe("semantic-release", () => {
`);
expect(setOutputMock.mock.calls).toMatchInlineSnapshot(`
[
[
"last-release-version",
"1.2.3-test",
],
[
"last-release-major-version",
1,
],
[
"new-release-published",
"true",
],
[
"new-release-type",
"prerelease",
],
[
"new-release-notes",
"New Release notes",
Expand Down

0 comments on commit 11fe39f

Please sign in to comment.