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 bcba1a7
Show file tree
Hide file tree
Showing 8 changed files with 44 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v3
- uses: ./release-notes-preview
- uses: ./lint-release-notes
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
lint:
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>
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 bcba1a7

Please sign in to comment.