-
Notifications
You must be signed in to change notification settings - Fork 1
94 lines (84 loc) · 2.9 KB
/
make-release.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
name: make-release
on:
workflow_dispatch:
inputs:
target_branch:
description: >-
JSON array of branches to target. The first branch in the array will
be marked as the latest release.
required: false
type: string
default: '["main"]'
jobs:
bump-version:
strategy:
matrix:
target_branch: ${{ fromJSON(inputs.target_branch) }}
runs-on: ubuntu-latest
env:
CARGO_EDIT_VERSION: 0.12.2
steps:
- uses: actions/checkout@v4
with:
ref: '${{ matrix.target_branch }}'
token: '${{ secrets.DIVVIUP_GITHUB_AUTOMATION_RELEASE_PAT }}'
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Cache cargo edit
uses: actions/cache@v4
with:
path: ${{ runner.tool_cache }}/cargo-edit
key: cargo-edit-${{ env.CARGO_EDIT_VERSION }}
- name: Add the tool cache directory to the search path
run: echo "${{ runner.tool_cache }}/cargo-edit/bin/" >>$GITHUB_PATH
- name: Ensure cargo-edit is installed
run: |
cargo install \
--root ${{ runner.tool_cache }}/cargo-edit \
--version ${{ env.CARGO_EDIT_VERSION }} \
cargo-edit
- run: cargo set-version --bump patch
- run: git diff
- name: Push changes
env:
ACTOR: '${{ github.actor }}'
run: |
git config user.email "divviup-github-automation@divviup.org"
git config user.name "divviup-github-automation"
git commit -am "Bump divviup-api patch version, triggered by @$ACTOR"
git push
# This job is kept separate from the previous one to enable retrying it without
# bumping the version number again.
make-release:
strategy:
matrix:
target_branch: ${{ fromJSON(inputs.target_branch) }}
runs-on: ubuntu-latest
needs: [bump-version]
steps:
- uses: actions/checkout@v4
with:
ref: '${{ matrix.target_branch }}'
token: '${{ secrets.DIVVIUP_GITHUB_AUTOMATION_RELEASE_PAT }}'
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
- name: Create release
env:
GH_TOKEN: '${{ secrets.DIVVIUP_GITHUB_AUTOMATION_RELEASE_PAT }}'
TARGET_BRANCH: '${{ matrix.target_branch }}'
FIRST_BRANCH: '${{ fromJSON(inputs.target_branch)[0] }}'
run: |
# Determine the workspace version.
VERSION=$(cargo metadata --no-deps --format-version 1 | jq -er '.packages[0].version')
LATEST=
if [ "$TARGET_BRANCH" == "$FIRST_BRANCH" ]; then
LATEST="--latest=true"
else
LATEST="--latest=false"
fi
gh release create "$VERSION" \
--generate-notes \
--target "$TARGET_BRANCH" \
$LATEST