watchexec/.github/workflows/release-pr.yml

106 lines
3.2 KiB
YAML
Raw Normal View History

2022-06-15 05:25:05 +02:00
name: Open a release PR
on:
workflow_dispatch:
inputs:
crate:
description: Crate to release
required: true
type: choice
options:
2022-06-15 05:25:05 +02:00
- cli
- lib
- filterer-globset
- filterer-ignore
- filterer-tagged
- ignore-files
- project-origins
version:
description: Version to release
required: true
type: string
jobs:
make-release-pr:
2022-06-15 05:25:05 +02:00
runs-on: ubuntu-latest
steps:
- name: Install cargo-release
uses: baptiste0928/cargo-install@v1
with:
crate: cargo-release
version: "0.21"
- uses: actions/checkout@v2
with:
ref: main
- name: Extract info
2022-06-15 05:25:05 +02:00
run: |
set -euxo pipefail
if [[ "${{ inputs.crate }}" == filterer-* ]]; then
crate_path="crates/$(tr '-' '/' <<< "${{ inputs.crate }}")"
else
crate_path="crates/${{ inputs.crate }}"
fi
pushd "$crate_path"
2022-06-15 05:25:05 +02:00
crate_name=$(head Cargo.toml -n2 | grep name | cut -d '"' -f2)
popd
branch_name="release-${{ inputs.crate }}-${{ inputs.version }}"
echo "crate_name=${crate_name}" >> $GITHUB_ENV
echo "crate_path=${crate_path}" >> $GITHUB_ENV
echo "branch_name=${branch_name}" >> $GITHUB_ENV
- name: Make release branch
run: git switch -c "${{ env.branch_name }}"
2022-06-15 05:25:05 +02:00
- name: Do release
run: |
set -euxo pipefail
git config user.name github-actions
git config user.email github-actions@github.com
cargo release \
--execute \
--no-push \
--no-tag \
--no-publish \
--no-confirm \
--verbose \
--config "${{ env.crate_path }}/release.toml" \
--allow-branch "${{ env.branch_name }}" \
2022-06-16 10:17:04 +02:00
--dependent-version upgrade \
2022-06-15 05:25:05 +02:00
--package "${{ env.crate_name }}" \
"${{ inputs.version }}"
- name: Push new branch
run: |
set -euxo pipefail
git push origin "${{ env.branch_name }}"
2022-06-15 05:25:05 +02:00
- name: Create PR
run: |
2022-06-15 05:25:05 +02:00
set -euxo pipefail
nl=$'\n'
br=$'\n\n'
fence=$'```\n'
ecnef=$'\n```'
2022-06-15 05:25:05 +02:00
title="release: ${{ inputs.crate }} v${{ inputs.version }}"
body_intro="This is a release PR for **${{ inputs.crate }}** to version **${{ inputs.version }}**."
2022-06-15 05:25:05 +02:00
if [[ "${{ inputs.crate }}" == "cli" ]]; then
body_merge="Upon merging, this will automatically build the CLI and create a GitHub release. You still need to manually publish the cargo crate."
2022-06-15 05:25:05 +02:00
else
body_merge="Upon merging, you will still need to manually publish the cargo crate."
2022-06-15 05:25:05 +02:00
fi
body_outro="${fence}$ cd crates/${{ env.crate_path }}${nl}$ cargo publish${ecnef}${br}To merge this release, review the changes then say:${br}\`bors r+ p=10\`"
2022-06-15 05:25:05 +02:00
body="${body_intro}${br}${body_merge}${br}${body_outro}"
2022-06-15 05:25:05 +02:00
2022-06-16 10:54:21 +02:00
gh pr create --title "$title" --body "$body" --base main --head "${{ env.branch_name }}" --label "release"
2022-06-15 05:25:05 +02:00
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}