This repository has been archived by the owner on Sep 12, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 17
94 lines (82 loc) · 3.32 KB
/
draft-new-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: "Draft new release"
on:
workflow_dispatch:
inputs:
version:
description: "The new version in X.Y.Z format."
required: true
jobs:
draft-new-release:
name: "Draft a new release"
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
env:
RELEASE_BRANCH: release/${{ github.event.inputs.version }}
steps:
- uses: actions/checkout@v3
with:
token: ${{ secrets.ITCHY_GITHUB_TOKEN }}
- name: Create release branch
run: git checkout -b ${{ env.RELEASE_BRANCH }}
- name: Initialize mandatory git config
run: |
git config user.name "${{ secrets.ITCHY_NAME }}"
git config user.email ${{ secrets.ITCHY_EMAIL }}
- name: Update changelog
uses: thomaseizinger/keep-a-changelog-new-release@v1
with:
version: ${{ github.event.inputs.version }}
- name: Bump version in Cargo.toml
uses: thomaseizinger/[email protected]
with:
version: ${{ github.event.inputs.version }}
manifest: daemon/Cargo.toml
- name: Bump version for taker-electron build file
uses: jaywcjlove/github-action-package@main
with:
path: taker-electron/release/app/package.json
data: |
{
"version": "${{github.event.inputs.version}}"
}
- name: Bump version for taker-electron package file
uses: jaywcjlove/github-action-package@main
with:
path: taker-electron/package.json
data: |
{
"version": "${{github.event.inputs.version}}"
}
- name: Update Cargo.lock
run: cargo update --workspace
- name: Commit changelog and manifest files
id: make-commit
run: |
curl -fsSL https://dprint.dev/install.sh | sh
/home/runner/.dprint/bin/dprint fmt
git add CHANGELOG.md Cargo.lock daemon/Cargo.toml taker-electron/package.json taker-electron/release/app/package.json
git commit --message "Prepare release ${{ github.event.inputs.version }}"
echo "::set-output name=commit::$(git rev-parse HEAD)"
- name: Create pull request
run: |
# Force push to allow for easier re-runs of the action
git push origin ${{ env.RELEASE_BRANCH }} --force
# Use heredoc to define multiline string: https://stackoverflow.com/a/23930212/2489334
BODY=$(cat <<-EOF
Hi @${{ github.actor }}!
This PR was created in response to a manual trigger of the release workflow here: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}.
I've bumped the versions in the manifest files in this commit: ${{ steps.make-commit.outputs.commit }}.
Merging this PR will create a GitHub release!
EOF
)
gh pr create \
--reviewer ${{ github.actor }} \
--title "Release version ${{ github.event.inputs.version }}" \
--head ${{ env.RELEASE_BRANCH }} \
--body "$BODY"
env:
# Using a bot account is important to trigger subsequent workflows.
# See https://devopsdirective.com/posts/2020/07/stupid-github-actions/#2----recursive-action.
GITHUB_TOKEN: ${{ secrets.ITCHY_GITHUB_TOKEN }}