-
-
Notifications
You must be signed in to change notification settings - Fork 0
70 lines (61 loc) · 2.47 KB
/
generate-release-target.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
# SPDX-License-Identifier: MIT
# SPDX-FileCopyrightText: "2022 smdn <smdn@smdn.jp>"
name: Generate release target
on:
push:
tags: new-release/*/*
workflow_dispatch:
inputs:
release_target_tag_name:
description: "The tag name of release target."
required: true
type: string
dry_run:
description: "If true, performs a trial run."
required: false
type: boolean
default: false
jobs:
determine-release-target:
runs-on: ubuntu-latest
outputs:
tag_name: ${{ steps.release-target.outputs.tag_name }}
dry_run: ${{ steps.release-target.outputs.dry_run }}
steps:
- name: Determine the release target tag
id: release-target
run: |
# If workflow is trigged by workflow_dispatch, the value of github.ref_name contains branch ref which workflow runs from.
# Due to the reason of above, github.event.inputs.release_target_tag_name must be tested before testing github.ref_name.
if [[ -n '${{ github.event.inputs.release_target_tag_name }}' ]]; then
# use dispatched tag name
echo '::set-output name=tag_name::${{ github.event.inputs.release_target_tag_name }}'
if [ '${{ github.event.inputs.dry_run }}' = 'true' ]; then
echo '::set-output name=dry_run::true'
else
echo '::set-output name=dry_run::false'
fi
exit 0
fi
if [[ -n '${{ github.ref_name }}' ]]; then
# use pushed tag name
echo '::set-output name=tag_name::${{ github.ref_name }}'
echo '::set-output name=dry_run::false'
exit 0
fi
echo "::error::release target tag could not be determined."
exit 1
run-generate-release-target:
uses: smdn/Smdn.Fundamentals/.github/workflows/generate-release-target.yml@workflows/release-target-v1.3.0
needs: determine-release-target
if: startsWith(needs.determine-release-target.outputs.tag_name, 'new-release/')
with:
release_target_tag_name: ${{ needs.determine-release-target.outputs.tag_name }}
release_target_tag_prefix: 'new-release/'
release_target_pr_label: 'release-target'
release_tag_prefix: 'releases/'
dry_run: ${{ fromJSON(needs.determine-release-target.outputs.dry_run) }}
secrets:
token_repo: ${{ secrets.PUBLISH_NEW_RELEASE }}
token_pullrequest: ${{ secrets.PUBLISH_NEW_RELEASE }}
token_gist: ${{ secrets.PUBLISH_NEW_RELEASE }}