-
Notifications
You must be signed in to change notification settings - Fork 0
83 lines (70 loc) · 2.41 KB
/
Copy pathrelease.yml
File metadata and controls
83 lines (70 loc) · 2.41 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
permissions:
contents: write
name: Build and Package Source ZIP
on:
workflow_dispatch:
inputs:
version:
description: 'Release tag (e.g., V3)'
required: true
jobs:
package:
runs-on: ubuntu-latest
permissions:
contents: read
outputs:
artifact_name: ${{ steps.gen.outputs.artifact_name }}
release_date: ${{ steps.current_time.outputs.year }}${{ steps.current_time.outputs.month }}${{ steps.current_time.outputs.day }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get current date
id: current_time
uses: josStorer/get-current-time@v2
with:
format: 'YYYYMMDD'
- name: Generate artifact filename
id: gen
run: |
TAG=${{ github.event.inputs.version }}
DATE=${{ steps.current_time.outputs.formattedTime }}
echo "artifact_name=FileHasher_${TAG}-${DATE}.zip" >> $GITHUB_OUTPUT
- name: Create ZIP
run: zip -r "${{ steps.gen.outputs.artifact_name }}" . -x ".git/*" ".github/*"
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ steps.gen.outputs.artifact_name }}
path: ${{ steps.gen.outputs.artifact_name }}
release:
needs: package
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Generate release notes
id: notes
run: |
PREV_TAG=$(git tag --sort=-creatordate | grep -v "${{ github.event.inputs.version }}" | head -n1)
[ -z "$PREV_TAG" ] && PREV_TAG=$(git rev-list --max-parents=0 HEAD)
git log $PREV_TAG..HEAD --pretty=format:'- %s ([%h](https://github.com/'"$GITHUB_REPOSITORY"'/commit/%H))' > notes.md
- name: Download artifact
uses: actions/download-artifact@v4
with:
name: ${{ needs.package.outputs.artifact_name }}
path: .
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ github.event.inputs.version }}
name: ${{ github.event.inputs.version }}-${{ needs.package.outputs.release_date }}
body_path: notes.md
files: ${{ needs.package.outputs.artifact_name }}
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}