-
Notifications
You must be signed in to change notification settings - Fork 8
63 lines (60 loc) · 3.08 KB
/
rust-bump-version.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
name: Bump Version
on:
workflow_call:
inputs:
base:
description: 'Name of branch to open PR against'
type: 'string'
default: 'main'
version:
description: 'Version to bump to (e.g. 0.1.0)'
type: 'string'
required: true
jobs:
bump-version:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: stellar/actions/rust-cache@main
- run: rustup update
- uses: stellar/binaries@v21
with:
name: cargo-edit
version: 0.11.6
- id: set-version
continue-on-error: true
run: |
cargo set-version ${{ inputs.version }}
- name: Create Commit
run: |
git config user.name 'github-actions[bot]'
git config user.email '41898282+github-actions[bot]@users.noreply.github.com'
git checkout -b 'release/v${{ inputs.version }}'
git add .
git commit -m 'Bump version to ${{ inputs.version }}'
git push origin 'release/v${{ inputs.version }}'
- name: Create Pull Request
uses: actions/github-script@v6
id: create-pull-request
with:
script: |
const response = await github.rest.pulls.create({
title: 'Bump version to ${{ inputs.version }}',
owner: context.repo.owner,
repo: context.repo.repo,
head: 'release/v${{ inputs.version }}',
base: '${{ inputs.base }}',
body: '### What\nBump version to ${{ inputs.version }}, creating release branch.\n\n### Why\nTriggered by @${{ github.actor }} in ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}.\n\n### What is next\n\nSee the release instructions for a full rundown on the release process:\nhttps://github.com/stellar/actions/blob/main/README-rust-release.md\n\nCommit any changes to the `release/v${{ inputs.version }}` branch that are needed in this release.\n\nIf this is a regular release releasing from `main`, merge this PR when ready, and after merging, create a release for this version by going to this link: https://github.com/${{ github.repository }}/releases/new?tag=v${{ inputs.version }}&title=${{ inputs.version }}\n\nIf this is a backport or patch release of a past version, see the release instructions. When ready to release this branch create a release by going to this link: \nhttps://github.com/${{ github.repository }}/releases/new?tag=v${{ inputs.version }}&title=${{ inputs.version }}&target=release/v${{ inputs.version }}'
});
return response.data.number;
- name: Comment on the Pull Request about Failure
if: steps.set-version.outcome == 'failure'
uses: actions/github-script@v6
with:
script: |
github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: ${{steps.create-pull-request.outputs.result}},
body: '🚨 There was an error setting versions when bumping version. Check out the GitHub Action that triggered this Pull Request for more information. Inspect the diff before merging.',
})