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

chore(ribir): 🤖 create a GitHub release for every alpha release #498

Merged
merged 1 commit into from
Dec 22, 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
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 "Adoo@outlook.com"
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 @@ -59,11 +59,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},
]