-
Notifications
You must be signed in to change notification settings - Fork 1
54 lines (43 loc) · 1.4 KB
/
Copy pathcreate-release.yml
File metadata and controls
54 lines (43 loc) · 1.4 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
name: Create Release from archives
on:
workflow_call:
push:
branches:
- main
paths:
- 'archives/**/*.md'
permissions:
contents: write
jobs:
create-release:
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
ref: main
fetch-depth: 2 # For git diff
- name: Generate tag name
id: tag
run: |
TAG_NAME="archives-$(date +'%Y%m%d')-${GITHUB_SHA::7}"
echo "tag_name=$TAG_NAME" >> $GITHUB_OUTPUT
- name: Detect changed archive file
id: archive
run: |
echo "Changed files:"
git diff-tree --no-commit-id --name-only -r HEAD
FILE=$(git diff-tree --no-commit-id --name-only -r HEAD | grep "^archives/.*\.md$" | head -n 1)
if [ -z "$FILE" ]; then
echo "Error: No archives changes detected"
exit 1
fi
echo "file=$FILE" >> $GITHUB_OUTPUT
- name: Create Release (with archive URL)
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
FILE_URL="https://github.com/${{ github.repository }}/blob/main/${{ steps.archive.outputs.file }}"
gh release create "${{ steps.tag.outputs.tag_name }}" \
--title "Release ${{ steps.tag.outputs.tag_name }}" \
--notes "📄 $FILE_URL"