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 automation to release new crates #374

Merged
merged 4 commits into from
May 1, 2024
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
11 changes: 11 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: weekly

- package-ecosystem: "cargo"
directory: "/"
schedule:
interval: "weekly"
14 changes: 14 additions & 0 deletions .github/workflows/automerge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: "Bot auto-{approve,merge}"

on:
workflow_dispatch:
pull_request_target:

permissions:
pull-requests: write
contents: write

jobs:
dependabot:
uses: yettoapp/actions/.github/workflows/automerge_dependabot.yml@main
secrets: inherit
104 changes: 104 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
name: Release and publish

on:
workflow_dispatch:

permissions:
contents: write
pull-requests: write

jobs:
release:
runs-on: ubuntu-latest

outputs:
version: ${{ steps.version-label.outputs.version }}

steps:
- uses: actions/checkout@v4
with:
submodules: true

- name: Setup Rust
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true

- name: Configure Git
run: |
git config --local user.email "actions@github.com"
git config --local user.name "Actions Auto Build"

- name: Get current version
id: version-label
run: |
VERSION=$(grep version Cargo.toml | head -n 1 | cut -d'"' -f2)
echo "version=${VERSION}" >> $GITHUB_OUTPUT

- name: Get previous version
id: previous-version-label
run: |
PREVIOUS_VERSION=$(gh api "/repos/${{ github.repository }}/tags?per_page=1" | jq -r '.[] | .name?')
echo "previous_version=${PREVIOUS_VERSION}" >> $GITHUB_OUTPUT

- name: Generate Release Notes
id: generate-release-notes
run: |
generate() {
gh api \
--method POST \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
/repos/${{ github.repository }}/releases/generate-notes \
-f tag_name='v${{ steps.version-label.outputs.version }}' \
-f previous_tag='v${{ steps.previous-version-label.outputs.previous_version }}' \
| jq -r ".body"
}
echo "changelog<<EOF"$'\n'"$(generate)"$'\n'EOF >> $GITHUB_OUTPUT

- name: Update CHANGELOG.md
run: |
echo "## [v${{ steps.version-label.outputs.version }}] - `date +%d-%m-%Y`" >> CHANGELOG.md.tmp
echo "${{steps.generate-release-notes.outputs.changelog}}" >> CHANGELOG.md.tmp
echo '-n' >> CHANGELOG.md
cat CHANGELOG.md >> CHANGELOG.md.tmp
mv CHANGELOG.md.tmp CHANGELOG.md

- name: Update README
run: |
cargo run --example update-readme

- name: Commit Changelog and README
run: |
git config --local user.email "actions@github.com"
git config --local user.name "Actions Auto Build"
git add -f CHANGELOG.md README.md
git commit -m "[auto-docs][skip test]: update changelog" || true

- name: Create tag
run: |
git tag -a v${{ steps.version-label.outputs.version }} -m "Release v${{ steps.version-label.outputs.version }}"
git push origin --tags

- name: Publish GitHub release
run: |
gh release create v${{ steps.version-label.outputs.version }} --generate-notes

publish:
needs: release
runs-on: ubuntu-latest
env:
CRATES_IO_TOKEN: ${{ secrets.CRATES_IO_TOKEN }}

steps:
- uses: actions/checkout@v4
with:
submodules: recursive

- name: Login to Crates.io
run: cargo login ${CRATES_IO_TOKEN}

- name: Publish crate
run: cargo publish
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "comrak"
version = "0.23.0"
version = "0.23.1-pre.1"
authors = ["Amelia Cuss <amelia@kivikakk.ee>"]
rust-version = "1.62.1"
description = "A 100% CommonMark-compatible GitHub Flavored Markdown parser and formatter"
Expand Down
Loading