-
Notifications
You must be signed in to change notification settings - Fork 208
87 lines (75 loc) · 2.89 KB
/
draft.yaml
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
name: Draft release
on:
push:
branches:
- master
env:
CARGO_TERM_COLOR: always
jobs:
draft:
strategy:
matrix:
crate:
- utoipa
- utoipa-gen
- utoipa-swagger-ui-vendored
- utoipa-swagger-ui
- utoipa-redoc
- utoipa-rapidoc
- utoipa-scalar
- utoipa-axum
- utoipa-config
- utoipa-actix-web
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: ./.github/actions/gitlog
name: Get changed commits
id: gitlog
with:
output-file: ./draft-gitlog.md
crate: ${{ matrix.crate }}
- name: Prepare changes
run: |
echo "## What's New :gem: :new: :tada:" > ./draft-changes.md
cat < ./draft-gitlog.md >> ./draft-changes.md
- name: Get release info
id: release_info
run: |
module="${{ matrix.crate }}"
version=$(cargo metadata --format-version=1 --no-deps | jq -r '.packages[] | select(.name | test("'"$module"'$")) | .version')
prerelease=false
if [[ "$version" =~ .*-.* ]]; then
prerelease=true
fi
echo "is_prerelease=$prerelease" >> $GITHUB_OUTPUT
echo "version=$version" >> $GITHUB_OUTPUT
- name: Add full change log link
run: |
echo -e "#### Full [change log](${{ github.server_url }}/${{ github.repository }}/compare/${{ steps.gitlog.outputs.last_release }}...${{ matrix.crate }}-${{ steps.release_info.outputs.version }})" >> ./draft-changes.md
- name: Check existing release
id: existing_release
run: |
if git tag | grep -e ^${{ matrix.crate }}-${{ steps.release_info.outputs.version }}$ > /dev/null; then
echo "Tag tag with ${{ matrix.crate }}-${{ steps.release_info.outputs.version }} already exists, cannot draft a release for already existing tag!, Consider upgrading versions to Cargo.toml file"
echo "is_new=false" >> $GITHUB_OUTPUT
else
echo "is_new=true" >> $GITHUB_OUTPUT
fi
- name: Remove previous release
if: ${{ steps.existing_release.outputs.is_new == 'true' }}
run: |
echo ${{ secrets.GITHUB_TOKEN }} | gh auth login --with-token
gh release delete ${{ matrix.crate }}-${{ steps.release_info.outputs.version }} -y || true
- name: Create release
id: create_release
if: ${{ steps.existing_release.outputs.is_new == 'true' }}
uses: softprops/[email protected]
with:
tag_name: ${{ matrix.crate }}-${{ steps.release_info.outputs.version }}
name: ${{ matrix.crate }}-${{ steps.release_info.outputs.version }}
body_path: ./draft-changes.md
draft: true
prerelease: ${{ steps.release_info.outputs.is_prerelease }}