-
Notifications
You must be signed in to change notification settings - Fork 0
61 lines (51 loc) · 1.87 KB
/
test.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
name: Release on Version Change
on:
push:
paths:
- '.version'
jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Read version
id: get_version
run: echo "VERSION=$(cat .version)" >> $GITHUB_ENV
- name: Determine if it's a pre-release
id: pre_release_check
run: |
if [[ "${{ env.VERSION }}" == 0* ]]; then
echo "PRE_RELEASE=true" >> $GITHUB_ENV
else
echo "PRE_RELEASE=false" >> $GITHUB_ENV
fi
- name: Get repository name
id: get_repo_name
run: echo "REPO_NAME=$(echo ${{ github.repository }} | cut -d'/' -f2)" >> $GITHUB_ENV
- name: Create a tar.gz archive
run: |
mkdir release
# Copy the files you want to include in the release, excluding unwanted ones
rsync -av --progress . ./release --exclude=".git" --exclude=".github" --exclude="excluded_file_or_folder"
# Create a tar.gz archive using the repository name and version, save it outside the release directory
tar -czvf ./${{ env.REPO_NAME }}_${{ env.VERSION }}.tar.gz -C release .
- name: Create GitHub Release
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ env.VERSION }}
name: "Release ${{ env.VERSION }}"
body: "Automated release of version ${{ env.VERSION }}."
prerelease: ${{ env.PRE_RELEASE }}
files: "${{ env.REPO_NAME }}_${{ env.VERSION }}.tar.gz"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Generate changelog from commits
id: generate_changelog
run: |
echo "CHANGELOG=$(git log -1 --pretty=%B)" >> $GITHUB_ENV
- name: Update release with changelog
run: |
gh release edit ${{ env.VERSION }} --notes "${{ env.CHANGELOG }}"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}