-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaction.yml
More file actions
107 lines (95 loc) · 3.15 KB
/
Copy pathaction.yml
File metadata and controls
107 lines (95 loc) · 3.15 KB
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
95
96
97
98
99
100
101
102
103
104
105
106
107
---
name: "Check Changelog"
description: "Verify many things in changelog"
inputs:
python-version:
description: "Python version to use with uv"
required: false
default: "3.12"
file-path:
description: "Path to the changelog file to process"
required: false
default: "./CHANGELOG.txt"
check-format:
description: "Whether to run the check-format step (boolean)"
required: false
default: "true"
get-tag:
description: "Use 'from-push' for push tag or specify a ref manually."
required: false
default: ""
summarize-news:
description: >
Use 'from-pr' for PRs, or provide ["<file_path>","<target_branch>"].
required: false
default: ""
runs:
using: "composite"
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup uv
uses: astral-sh/setup-uv@v5
with:
python-version: "${{ inputs.python-version }}"
- id: format
name: Check format
if: ${{ fromJSON(inputs.check-format) }}
shell: bash
run: |
echo "Checking format..."
uv run --with '${{ github.action_path }}' \
changelogtxt check-format \
-f ${{ inputs.file-path }}
- id: tag-push
name: Get pushed tag
env:
IS_PUSH: ${{ github.event_name == 'push' && github.ref_type == 'tag' }}
if: ${{ inputs.get-tag == 'from-push' && env.IS_PUSH == 'true' }}
shell: bash
run: |
echo "Checking tag..."
uv run --with "${{ github.action_path }}" \
changelogtxt get-tag "${{ github.ref_name }}" \
-f "${{ inputs.file-path }}"
- id: tag
name: Get tag
if: ${{ inputs.get-tag != '' && inputs.get-tag != 'from-push' }}
shell: bash
run: |
echo "Checking tag..."
uv run --with "${{ github.action_path }}" \
changelogtxt get-tag "${{ inputs.get-tag }}" \
-f ${{ inputs.file-path }}
- id: summarize-push
name: Summarize news from push
env:
IS_PR: ${{ github.event_name == 'pull_request' }}
FILE_PATH: ${{ inputs.file-path }}
if: ${{ inputs.summarize-news == 'from-pr' && env.IS_PR == 'true' }}
shell: bash
run: |
set -euo pipefail
echo "Checking files"
HEAD_BRANCH=${{ github.event.pull_request.head.ref }}
BASE_BRANCH=${{ github.event.pull_request.base.ref }}
git show "origin/$BASE_BRANCH:$FILE_PATH" > origin.txt
git show "origin/$HEAD_BRANCH:$FILE_PATH" > target.txt
uv run --with '${{ github.action_path }}' \
changelogtxt summarize-news origin.txt target.txt
- id: summarize
name: Summarize news
env:
SUMMARIZE: ${{ inputs.summarize-news }}
if: ${{ env.SUMMARIZE != '' && env.SUMMARIZE != 'from-pr' }}
shell: bash
run: |
set -euo pipefail
echo "Checking files"
FILE_PATH=$(echo "$SUMMARIZE" | jq -r '.[0]')
TARGET_BRANCH=$(echo "$SUMMARIZE" | jq -r '.[1]')
git show "origin/$TARGET_BRANCH:$FILE_PATH" > target.txt
uv run --with '${{ github.action_path }}' \
changelogtxt summarize-news "$FILE_PATH" target.txt