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

feat(semantic-release): adds last-release outputs #21

Merged
merged 1 commit into from
Sep 14, 2023
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
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 |
Comment on lines +52 to +58
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tagoro9 good call. Fixed and added the others too.


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