Skip to content

Commit

Permalink
ci: auto PR
Browse files Browse the repository at this point in the history
  • Loading branch information
tkrs committed Jan 3, 2024
1 parent ea95466 commit 620b95f
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 16 deletions.
29 changes: 13 additions & 16 deletions .github/workflows/release.yml → .github/workflows/pr.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
name: Release
name: Create Release PR

on:
workflow_dispatch:

permissions:
contents: write
pull-requests: write

jobs:
release-crate:
environment: crates-io
create-pr:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GH_PAT }}
- name: Setup git user
run: |
git config user.email "type.in.type@gmail.com"
git config user.name "Takeru Sato"
- name: Install rust toolchain stable
uses: dtolnay/rust-toolchain@v1
with:
Expand All @@ -37,12 +35,11 @@ jobs:
uses: taiki-e/install-action@v2
with:
tool: cargo-release
- run: cargo release ${{ steps.release_context.outputs.version }} --execute --no-confirm
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
- name: Create release
uses: softprops/action-gh-release@v1
- run: cargo release ${{ steps.release_context.outputs.version }} --execute --no-confirm --no-tag --no-push --no-publish
- run: git reset --soft HEAD^
- name: Create Pull Request
uses: peter-evans/create-pull-request@v5
with:
name: Release ${{ steps.release_context.outputs.tag_name }}
tag_name: ${{ steps.release_context.outputs.tag_name }}
body_path: RELEASE_BODY.md
commit-message: "chore(release): ${{ steps.release_context.outputs.tag_name }}"
branch: "release/${{ steps.release_context.outputs.tag_name }}"
body-path: RELEASE_BODY.md
33 changes: 33 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Publish to crate.io

on:
push:
tags: ["v*"]

jobs:
publish-crate:
environment: crates-io
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install rust toolchain stable
uses: dtolnay/rust-toolchain@v1
with:
toolchain: stable
target: x86_64-unknown-linux-gnu
- name: Generate release context
id: release_context
run: |
tag="$(git describe HEAD --abbrev=0)"
echo "tag_name=$tag" >>$GITHUB_OUTPUT
echo "version=${tag/v/}" >>$GITHUB_OUTPUT
git log --pretty=format:'%b' --no-merges -1 >RELEASE_BODY.md
- run: cargo publish
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
- name: Create release
uses: softprops/action-gh-release@v1
with:
name: Release ${{ steps.release_context.outputs.tag_name }}
tag_name: ${{ steps.release_context.outputs.tag_name }}
body_path: RELEASE_BODY.md
27 changes: 27 additions & 0 deletions .github/workflows/tagging.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Create Rlease Tag

on:
push:
branches: [master]

jobs:
create-tag:
environment: crates-io
runs-on: ubuntu-latest
if: ${{ startsWith(github.event.head_commit.message, 'chore(release):') }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GH_PAT }}
- name: Setup git user
run: |
git config user.email "type.in.type@gmail.com"
git config user.name "Takeru Sato"
- name: Setup Node.js
uses: actions/setup-node@v4
- run: sudo npm install -g standard-version
- name: Determine tag and generate release body
run: standard-version --skip.changelog --skip.commit
- name: Publish tag
run: git push --follow-tags

0 comments on commit 620b95f

Please sign in to comment.