-
Notifications
You must be signed in to change notification settings - Fork 77
55 lines (53 loc) · 2.04 KB
/
reusable-release-cargo.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
name: Reusable Cargo Version Check
on:
workflow_call:
inputs:
package-name:
required: true
type: string
display-name:
required: true
type: string
jobs:
rust-version-release:
runs-on: ubuntu-latest
outputs:
release-cut: ${{ steps.output.outputs.release_cut }}
steps:
- uses: actions/checkout@v4
- run: git fetch --all --tags
- name: Check Release Version
id: release_version
uses: joroshiba/version-check@v2
with:
file: ${{ format('crates/astria-{0}/Cargo.toml', inputs.package-name) }}
tagFormat: ${{ format('{0}-v${{version}}', inputs.package-name) }}
failBuild: false
# Notice appears when the version has changed on a PR to main
- name: Release Notice
if: |
steps.release_version.outputs.versionChanged == 'true' &&
github.event_name == 'pull_request' &&
github.base_ref == 'main'
run: |
FILE="${{ format('crates/astria-{0}/Cargo.toml', inputs.package-name) }}"
TITLE="New ${{ inputs.display-name}} Release"
MESSAGE=("This PR updates the version of ${{ inputs.package-name }}."
"After merging a new release ${{steps.release_version.outputs.rawVersion}}"
"will be created with tag ${{ steps.release_version.outputs.releaseVersion }}."
)
echo "::warning file=$FILE,title=$TITLE::${MESSAGE[*]}"
# Actually release when version has changed on a push to main
- name: Release
if: |
steps.release_version.outputs.versionChanged == 'true' &&
github.event_name == 'push' &&
github.ref == 'refs/heads/main'
uses: actions/create-release@latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.release_version.outputs.releaseVersion }}
release_name: ${{ inputs.display-name }} ${{ steps.release_version.outputs.rawVersion }}
draft: true
prerelease: true