-
Notifications
You must be signed in to change notification settings - Fork 0
105 lines (89 loc) · 3.07 KB
/
mainaction.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
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
name: Download and Merge Zip Files
on:
workflow_dispatch:
schedule:
- cron: '0 0 * * 0' # Runs every week
jobs:
download-and-merge:
runs-on: ubuntu-latest
permissions:
contents: write
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Get current date
id: date
run: echo "::set-output name=date::$(date +'%Y-%m-%d')"
- name: Download first zip file
run: |
curl -L -o trid.zip https://mark0.net/download/trid_w32.zip
- name: Download second zip file
run: |
curl -L -o triddefs.zip https://mark0.net/download/triddefs.zip
- name: Unzip first file
run: |
unzip trid.zip -d extracted1
- name: Unzip second file
run: |
unzip triddefs.zip -d extracted2
- name: Merge directories
run: |
mkdir -p merged
cp -r extracted1/* merged/
cp -r extracted2/* merged/
- name: Create merged zip file
run: |
zip -r trid-bundled_${{ steps.date.outputs.date }}.zip merged
- name: Generate checksum for new zip
id: generate_new_checksum
run: |
sha256sum trid-bundled_${{ steps.date.outputs.date }}.zip > new_checksum.txt
- name: Download previous release
uses: actions/download-release-asset@v1
with:
owner: ${{ github.repository_owner }}
repo: ${{ github.event.repository.name }}
tag: latest
asset_name: last.zip
continue-on-error: true
- name: Generate checksum for previous zip
id: generate_previous_checksum
run: |
if [ -f last.zip ]; then
sha256sum merged.zip > previous_checksum.txt
else
echo "No previous release found" > previous_checksum.txt
fi
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: trid-bundled_${{ steps.date.outputs.date }}
path: trid-bundled_${{ steps.date.outputs.date }}.zip
- name: Compare checksums
id: compare_checksums
run: |
if [ -f previous_checksum.txt ] && cmp -s new_checksum.txt previous_checksum.txt; then
echo "Checksums match. No new release needed."
echo "checksums_match=true" >> $GITHUB_ENV
else
echo "Checksums do not match. Proceeding with release."
echo "checksums_match=false" >> $GITHUB_ENV
- name: Create GitHub Release
id: create_release
if: env.checksums_match == 'false'
uses: actions/create-release@v1
with:
tag_name: v1.0.${{ github.run_number }}
release_name: trid-bundled_${{ steps.date.outputs.date }}
draft: false
prerelease: false
- name: Upload Release Asset
if: env.checksums_match == 'false'
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: trid-bundled_${{ steps.date.outputs.date }}.zip
asset_name: trid-bundled_${{ steps.date.outputs.date }}.zip
asset_content_type: application/zip