Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.1k views
in Technique[技术] by (71.8m points)

sed - How to get release notes from Semantic Release output using grep command

I am trying to automate the release of software using semantic-release. Everything is working fine. I run this command npx semantic-release --no-ci --dry-run and get the following output in the terminal

...some other output

[1:01:55 pm] [semantic-release] ? ?  Skip v0.1.1 tag creation in dry-run mode
[1:01:55 pm] [semantic-release] ? ?  Published release 0.1.1 on default channel
[1:01:55 pm] [semantic-release] ? ?  Release note for version 0.1.1:
## 0.1.1 (2021-01-24)

### Bug Fixes

    * ravgeet is fixing things (92797f6)
    * removed unwanted files (bdcc9ff)
    * this is another fix (dbef2fd)

Now I need to get the release notes from the output

## 0.1.1 (2021-01-24)

### Bug Fixes

    * ravgeet is fixing things (92797f6)
    * removed unwanted files (bdcc9ff)
    * this is another fix (dbef2fd)

How can I do so using grep command or any other means?

question from:https://stackoverflow.com/questions/65868106/how-to-get-release-notes-from-semantic-release-output-using-grep-command

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

With GNU sed.

| sed -n '/^##/,$p'

-n: Do not output anything unless it is explicitly stated (here with command p)

x,yp: You can replace x and y with a regex (here: /^##/), a line number or a special character like $. $ matches here last line in input.

/^##/: regex for lines starting with two #

p output sed's pattern space (current line).


| sed '/^##/,$!d'is a more compact notation. I translate !d with don't delete.


See: man sed and The Stack Overflow Regular Expressions FAQ


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...