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

add release-notes output #28

Merged

Conversation

nbusseneau
Copy link
Contributor

Add a new release-notes output to the action containing the release notes for the newly released versions, allowing consumers to leverage it in their workflows (e.g. by passing it down to the GitHub Release API).

Closes: #27

Ensure all text files use LF, even on Windows, so as to avoid newline
headaches when running tests.
@nbusseneau
Copy link
Contributor Author

nbusseneau commented Jul 2, 2024

Important

I could not get npm run build to run because of npm dependency hell:

ERROR in index.js from Terser
Error: error:0308010C:digital envelope routines::unsupported

I spent 15 minutes trying to fix this mess and then remembered why I never wanted to touch these shenanigans ever again, so dist/index.js has NOT been updated as part of this PR. Big sorry, I hope you can make it work on your end.

npm run test does work fine though, here's the output with the new tests:

 PASS  __tests__/updateChangelog.test.ts
  √ should update empty_release changelog (22ms)
  √ should update standard changelog (4ms)                                                                                                                
  √ should update first_release changelog (2ms)                                                                                                           
  √ should update lowercase_link_reference changelog (4ms)                                                                                                
  √ should update tag_release changelog (3ms)                                                                                                             
  √ should update tag_on_tag changelog (3ms)                                                                                                              
                                                                                                                                                          
 PASS  __tests__/getReleaseNotes.test.ts                                                                                                                  
  √ should extract empty_release release-notes output (3ms)
  √ should extract standard release-notes output (3ms)                                                                                                    
  √ should extract first_release release-notes output (1ms)                                                                                               
  √ should extract lowercase_link_reference release-notes output (2ms)                                                                                    
  √ should extract tag_release release-notes output (2ms)                                                                                                 
  √ should extract tag_on_tag release-notes output (2ms)                                                                                                  
                                                                                                                                                          
 PASS  __tests__/getGenesisHash.test.ts                                                                                                                   
  √ should return a hash (46ms)
                                                                                                                                                          
 PASS  __tests__/getInputs.test.ts                                                                                                                        
  √ version or tag is required (4ms)
  √ tag is used before version (1ms)                                                                                                                      
  √ version fallback works (1ms)                                                                                                                          
  √ can parse prefixed tag                                                                                                                                
  √ date is optional but has a default                                                                                                                    
  √ parses date into ISO8601                                                                                                                              
  √ parses GITHUB_REPOSITORY into owner and repo                                                                                                          
  √ can handle ISO8601 date (1ms)                                                                                                                         
  √ changelog path is optional but has a default                                                                                                          
  √ parse changelog path from input                                                                                                                       
                                                                                                                                                          
 PASS  __tests__/formatDate.test.ts                                                                                                                       
  √ should format 'Dec 09 2019' as '2019-12-09'
  √ should format 'Dec 16 2019' as '2019-12-16' (1ms)                                                                                                     
  √ should format 'Jan 09 2019' as '2019-01-09'                                                                                                           
                                                                                                                                                          
Test Suites: 5 passed, 5 total                                                                                                                            
Tests:       26 passed, 26 total                                                                                                                          
Snapshots:   0 total
Time:        1.188s
Ran all test suites.

@thomaseizinger
Copy link
Owner

I spent 15 minutes trying to fix this mess and then remembered why I never wanted to touch these shenanigans ever again, so dist/index.js has NOT been updated as part of this PR. Big sorry, I hope you can make it work on your end.

We need to update that if we want to use this feature though!

Unfortunately, GitHub cannot natively execute TS in its actions and it is always the compiled JS that gets executed.

@thomaseizinger
Copy link
Owner

I could not get npm run build to run because of npm dependency hell:

This is a yarn project but yarn run build also fails for me locally. This is madness, how can this fail if we have a lockfile? I don't really have the time to dig into it sorry :(

@thomaseizinger
Copy link
Owner

Apparently it is an issue with an outdated Node version, so perhaps a dependency upgrade can fix it?

https://stackoverflow.com/questions/74726224/opensslerrorstack-error03000086digital-envelope-routinesinitialization-e

@nbusseneau
Copy link
Contributor Author

Apparently it is an issue with an outdated Node version, so perhaps a dependency upgrade can fix it?

https://stackoverflow.com/questions/74726224/opensslerrorstack-error03000086digital-envelope-routinesinitialization-e

Yea this what I tried to do initially but gave up when I saw the mess, I honestly don't want to ever again touch anything like that, I've been npm-free for years now...!

@nbusseneau
Copy link
Contributor Author

nbusseneau commented Jul 3, 2024

BTW not really related to the PR, but while we're at it and complaining about package.json hell: I noticed that Prettier was complaining the existing files were not conforming to the formatting config. For the PR I just kept the existing code style in place without touching anything, so it also does not conform to Prettier's config.

> yarn format-check
yarn run v1.22.22
$ prettier --check **/*.ts
Checking formatting...
__tests__\fixtures\empty_release\fixture.ts
__tests__\fixtures\first_release\fixture.ts
__tests__\fixtures\lowercase_link_reference\fixture.ts
__tests__\fixtures\standard\fixture.ts
__tests__\fixtures\tag_on_tag\fixture.ts
__tests__\fixtures\tag_release\fixture.ts
__tests__\getReleaseNotes.test.ts
__tests__\updateChangelog.test.ts
src\getReleaseNotes.ts
src\updateChangelog.ts
types\mock-env\index.d.ts
types\to-vfile\index.d.ts
Code style issues found in the above file(s). Forgot to run Prettier?

And also seemed like ESLint was complaining about its setup:

> yarn lint
yarn run v1.22.22
$ eslint src/**/*.ts

Oops! Something went wrong! :(

ESLint: 5.16.0.
ESLint couldn't find the plugin "eslint-plugin-prettier". This can happen for a couple different reasons:

1. If ESLint is installed globally, then make sure eslint-plugin-prettier is also installed globally. A globally-installed ESLint cannot find a locally-installed plugin.

2. If ESLint is installed locally, then it's likely that the plugin isn't installed correctly. Try reinstalling by running the following:

    npm i eslint-plugin-prettier@latest --save-dev

Path to ESLint package: C:\Workspace\Programming\GitHub\keep-a-changelog-new-release\node_modules\eslint

If you still can't figure out the problem, please stop by https://gitter.im/eslint/eslint to chat with the team.

error Command failed with exit code 2.

@nbusseneau
Copy link
Contributor Author

nbusseneau commented Jul 5, 2024

OK I bit the bullet and decided to go the full stupid route: I downgraded Node to v16.20.2 (instead of using the latest LTS like any sane person would do), and I can now run yarn build, because this old version does not have the security checks triggering the issue above. This is bad because the build uses an insecure version of libSSL but whatever, this runs in the context of controlled and ephemeral GitHub runners so the risk is benign.

Move Markdown node definitions to types, as we will be reusing them in
another file in the next commit.
Add a new `release-notes` output to the action containing the release
notes for the newly released versions, allowing consumers to leverage it
in their workflows (e.g. by passing it down to the GitHub Release API).
@nbusseneau nbusseneau force-pushed the pr/add-release-notes-output branch from 92915a2 to a700c0f Compare July 5, 2024 12:53
@nbusseneau
Copy link
Contributor Author

Rebased the commits and added an updated build of index.js on each relevant commit.

@nbusseneau
Copy link
Contributor Author

Tests are still passing:

> yarn test
yarn run v1.22.22
$ jest
 PASS  __tests__/updateChangelog.test.ts
  √ should update empty_release changelog (16ms)
  √ should update standard changelog (4ms)                                                                                                                                    
  √ should update first_release changelog (2ms)                                                                                                                               
  √ should update lowercase_link_reference changelog (3ms)                                                                                                                    
  √ should update tag_release changelog (4ms)                                                                                                                                 
  √ should update tag_on_tag changelog (3ms)                                                                                                                                  
                                                                                                                                                                              
 PASS  __tests__/getGenesisHash.test.ts                                                                                                                                       
  √ should return a hash (40ms)
                                                                                                                                                                              
 PASS  __tests__/getReleaseNotes.test.ts                                                                                                                                      
  √ should extract empty_release release-notes output (4ms)
  √ should extract standard release-notes output (2ms)                                                                                                                        
  √ should extract first_release release-notes output (2ms)                                                                                                                   
  √ should extract lowercase_link_reference release-notes output (1ms)                                                                                                        
  √ should extract tag_release release-notes output (2ms)                                                                                                                     
  √ should extract tag_on_tag release-notes output (2ms)                                                                                                                      
                                                                                                                                                                              
 PASS  __tests__/getInputs.test.ts                                                                                                                                            
  √ version or tag is required (6ms)
  √ tag is used before version                                                                                                                                                
  √ version fallback works (1ms)                                                                                                                                              
  √ can parse prefixed tag                                                                                                                                                    
  √ date is optional but has a default                                                                                                                                        
  √ parses date into ISO8601 (1ms)                                                                                                                                            
  √ parses GITHUB_REPOSITORY into owner and repo                                                                                                                              
  √ can handle ISO8601 date                                                                                                                                                   
  √ changelog path is optional but has a default                                                                                                                              
  √ parse changelog path from input                                                                                                                                           
                                                                                                                                                                              
 PASS  __tests__/formatDate.test.ts                                                                                                                                           
  √ should format 'Dec 09 2019' as '2019-12-09'
  √ should format 'Dec 16 2019' as '2019-12-16'                                                                                                                               
  √ should format 'Jan 09 2019' as '2019-01-09'                                                                                                                               
                                                                                                                                                                              
Test Suites: 5 passed, 5 total                                                                                                                                                
Tests:       26 passed, 26 total                                                                                                                                              
Snapshots:   0 total
Time:        1.083s
Ran all test suites.
::warning::Version argument will be deprecated soon, use tag instead.
Done in 1.67s.

Copy link
Owner

@thomaseizinger thomaseizinger left a comment

Choose a reason for hiding this comment

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

Sorry for the delay! Thank you for the contribution :)

@thomaseizinger thomaseizinger merged commit 0d79fe3 into thomaseizinger:master Jul 20, 2024
1 check passed
@thomaseizinger
Copy link
Owner

You should be able to depend on latest main now and use this. Let me know how that goes. I can make a release then :)

@nbusseneau
Copy link
Contributor Author

OK I'll probably release something in the next couple days, will let you know.

@nbusseneau
Copy link
Contributor Author

@thomaseizinger
Copy link
Owner

Awesome, thanks! Will release tomorrow.

@thomaseizinger
Copy link
Owner

Released: https://github.com/thomaseizinger/keep-a-changelog-new-release/releases/tag/3.1.0.

@baynezy
Copy link

baynezy commented Jul 29, 2024

@thomaseizinger / @nbusseneau do we as users need to do anything to take advantage of this?

@thomaseizinger
Copy link
Owner

thomaseizinger commented Jul 29, 2024

@thomaseizinger / @nbusseneau do we as users need to do anything to take advantage of this?

I am not sure I understand your question? Starting with this PR, the action emits an output called release-notes. What you do with that is up to you. If you want it to show up in a GitHub release, you can use the output as part of creating your release.

See @nbusseneau's workflow file: https://github.com/nbusseneau/LotusEcarlateChanges/actions/runs/10057749177/workflow#L64

@baynezy
Copy link

baynezy commented Jul 30, 2024

@thomaseizinger - sorry I understand now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

feature request: add a release-notes output to the action
3 participants