Skip to content

Commit

Permalink
chore(ribir): 🤖 create a GitHub release for every alpha release
Browse files Browse the repository at this point in the history
  • Loading branch information
M-Adoo committed Dec 7, 2023
1 parent 152a2b4 commit 4e4d105
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 9 deletions.
31 changes: 30 additions & 1 deletion .github/workflows/alpha-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ jobs:
release:
runs-on: ubuntu-22.04
steps:
- name: Exit if the branch is not master
run: |
if [[ "${{ github.ref }}" != "refs/heads/master" ]]; then
echo "Branch is not master, exiting."
exit 0
fi
- uses: actions/checkout@v3
with:
fetch-depth: 0 # Required to count the commits
Expand Down Expand Up @@ -39,9 +45,32 @@ jobs:
git config --global user.email "[email protected]"
git config --global user.name "Bot@Ribir"
- name: Run cargo release
- name: Run cargo release to publish
if: ${{ env.NEW_COMMIT_COUNT > 0 }}
uses: actions-rs/cargo@v1
with:
command: release
args: alpha --execute --no-confirm
- name: Extract changelog
if: ${{ env.NEW_COMMIT_COUNT > 0 }}
run: |
echo "TAG_NAME=$(git describe --tags --abbrev=0)" >> $GITHUB_ENV
version=$(git describe --tags --abbrev=0 | grep -oP '(?<=v)\S*')
echo "VERSION=$version" >> $GITHUB_ENV
{
echo 'CHANGELOG<<delimiter-for-changelog'
(
grep -zoP "(?:## \[${version}\])[\s\S]*(?=\s+##[^#])" ./CHANGELOG.md \
|| grep -zoP "(?:## ${version})[\s\S]*(?=\s+<\!--)" ./CHANGELOG.md
) \
| grep -zoP '\n[\s\S]*(?=\n)' | grep -zoP '\S[\s\S]*' \
| grep -aP '[\s\S]*' | sed -e '$a\'
echo 'delimiter-for-changelog'
} >> $GITHUB_ENV
- name: Github release notes
if: ${{ env.NEW_COMMIT_COUNT > 0 }}
uses: ncipollo/release-action@v1
with:
prerelease: true
body: ${{ env.CHANGELOG }}
tag: ${{ env.TAG_NAME }}
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ There are 5 types of changes:
And please only add new entries below the [Unreleased](#unreleased---releasedate) header with the following format:

```md
**crate or effect scope**: description of change ([#PR])
**crate or effect scope**: description of change (#PR @contributor)
```

<!-- next-header -->
Expand Down
14 changes: 7 additions & 7 deletions ribir/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,11 @@ raw-window-handle.workspace = true
[package.metadata.release]
tag = true
pre-release-replacements = [
{file="../CHANGELOG.md", search="@Unreleased", replace="{{version}}"},
{file="../CHANGELOG.md", search="\\.\\.\\.HEAD", replace="...{{tag_name}}", min=0},
{file="../CHANGELOG.md", search="@ReleaseDate", replace="{{date}}"},
{file="../CHANGELOG.md", search="<!-- next-header -->", replace="<!-- next-header -->\n\n## [@Unreleased] - @ReleaseDate", exactly=1},
{file="../CHANGELOG.md", search="<!-- next-url -->", replace="<!-- next-url -->\n[@Unreleased]: https://github.com/RibirX/Ribir/compare/{{tag_name}}...HEAD", exactly=1},
{file="../docs/zh/起步/创建一个应用.md", search="@RIBIR_VERSION", replace="{{version}}"},
{file="../docs/en/get_started/creating_an_application.md", search="@RIBIR_VERSION", replace="{{version}}"},
{file="../CHANGELOG.md", search="@Unreleased", replace="{{version}}", prerelease = true},
{file="../CHANGELOG.md", search="\\.\\.\\.HEAD", replace="...{{tag_name}}", min=0, prerelease = true},
{file="../CHANGELOG.md", search="@ReleaseDate", replace="{{date}}", prerelease = true},
{file="../CHANGELOG.md", search="<!-- next-header -->", replace="<!-- next-header -->\n\n## [@Unreleased] - @ReleaseDate", exactly=1, prerelease = true},
{file="../CHANGELOG.md", search="<!-- next-url -->", replace="<!-- next-url -->\n[@Unreleased]: https://github.com/RibirX/Ribir/compare/{{tag_name}}...HEAD", exactly=1, prerelease = true},
{file="../docs/zh/起步/创建一个应用.md", search="@RIBIR_VERSION", replace="{{version}}", prerelease = true},
{file="../docs/en/get_started/creating_an_application.md", search="@RIBIR_VERSION", replace="{{version}}", prerelease = true},
]

0 comments on commit 4e4d105

Please sign in to comment.