-
Notifications
You must be signed in to change notification settings - Fork 1
62 lines (52 loc) · 1.92 KB
/
auto_release.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
name: auto_release
on:
schedule:
- cron: '0 1 * * *'
workflow_dispatch:
jobs:
release-and-tag:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Download and rename latest release asset
id: download_latest_asset
run: |
gh release download --pattern "mosdns_config_*.tar.gz" --dir .
mv mosdns_config_*.tar.gz mosdns_config_latest.tar.gz
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Calculate sha256 of latest tarball
id: sha_latest_tarball
run: |
if [ -f mosdns_config_latest.tar.gz ]; then
echo "LATEST_TARBALL_HASH=$(sha256sum mosdns_config_latest.tar.gz | awk '{print $1}')" >> $GITHUB_ENV
else
echo "LATEST_TARBALL_HASH=" >> $GITHUB_ENV
fi
- name: Get the date
run: echo "DATE=$(date +'%Y%m%d')" >> $GITHUB_ENV
- name: Archive etc directory
run: git archive -o "mosdns_config_${{ env.DATE }}.tar.gz" HEAD etc/
- name: Calculate sha256 of new tarball
id: sha_new_tarball
run: echo "NEW_TARBALL_HASH=$(sha256sum mosdns_config_${{ env.DATE }}.tar.gz | awk '{print $1}')" >> $GITHUB_ENV
- name: Check if tarballs are different
run: |
if [ "$LATEST_TARBALL_HASH" != "$NEW_TARBALL_HASH" ]; then
echo "CHANGES_FOUND=true" >> $GITHUB_ENV
else
echo "CHANGES_FOUND=false" >> $GITHUB_ENV
fi
- name: Create Release and Upload Asset
if: env.CHANGES_FOUND == 'true'
uses: softprops/action-gh-release@v2
with:
tag_name: v${{ env.DATE }}
name: v${{ env.DATE }}
body: "Package etc directory on date ${{ env.DATE }}"
files: mosdns_config_${{ env.DATE }}.tar.gz
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}