-
Notifications
You must be signed in to change notification settings - Fork 46
143 lines (125 loc) · 5.58 KB
/
create-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
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
name: Create Release
permissions:
contents: write
on:
push:
# branches:
# - main
paths:
- '**.yml'
- '**.json'
- '!Apps_pre/**'
pull_request:
types: [closed]
branches:
- main
workflow_dispatch:
inputs:
tags:
description: 'Test tags'
required: true
type: string
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0 # Number of commits to fetch. 0 indicates all history for all branches and tags.
- name: Get Commit Messages
id: get_commit_messages
run: |
# Get the latest tag
LATEST_TAG=$(git tag --sort=-creatordate | head -n 1)
# If there is no latest tag, get only the latest commit message
if [ -z "$LATEST_TAG" ]; then
COMMITS=$(git log -1 --pretty=format:'- %s (%h)')
else
COMMITS=$(git log --pretty=format:'- %s (%h)' --no-merges "$LATEST_TAG"..HEAD)
fi
# Output Multi-Line String
echo "commits<<EOF" >> $GITHUB_OUTPUT
echo "$COMMITS" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
# Get the release date
RELEASE_DATE=$(date +'%Y%m%d')
echo "release_date=$RELEASE_DATE" >> $GITHUB_OUTPUT
- name: Delete tag and release
uses: dev-drprasad/delete-tag-and-release@v1.1
with:
tag_name: new
github_token: ${{ secrets.GITHUB_TOKEN }}
- name: Filter and Create Release
id: create_release
run: |
# Build universal
zip AppStore.zip $(find . -type f \( -wholename "./*.json" -o -wholename "./Apps/*.yml" \))
universal_count=$(find ./Apps/ -name "*.yml" | wc -l)
# Build arm
[ -d "./Apps_arm" ] && cp -rfu ./Apps_arm/* ./Apps/
zip AppStore_arm.zip $(find . -type f -wholename "./*.json" && find . -type f -wholename "./Apps/*.yml" -exec grep -rlPz 'x-casaos:\s*\n\s*architectures:[\n\s\w-#]*- arm\s*\n' {} \;)
arm_count=$(find . -type f -wholename "./Apps/*.yml" -exec grep -rlPz 'x-casaos:\s*\n\s*architectures:[\n\s\w-#]*- arm\s*\n' {} \; | wc -l)
git checkout -- ./Apps && git clean -df ./Apps
# Build arm64
[ -d "./Apps_arm64" ] && cp -rfu ./Apps_arm64/* ./Apps/
zip AppStore_arm64.zip $(find . -type f -wholename "./*.json" && find . -type f -wholename "./Apps/*.yml" -exec grep -rlPz 'x-casaos:\s*\n\s*architectures:[\n\s\w-#]*- arm64\s*\n' {} \;)
arm64_count=$(find . -type f -wholename "./Apps/*.yml" -exec grep -rlPz 'x-casaos:\s*\n\s*architectures:[\n\s\w-#]*- arm64\s*\n' {} \; | wc -l)
git checkout -- ./Apps && git clean -df ./Apps
# Build amd64
[ -d "./Apps_amd64" ] && cp -rfu ./Apps_amd64/* ./Apps/
zip AppStore_amd64.zip $(find . -type f -wholename "./*.json" && find . -type f -wholename "./Apps/*.yml" -exec grep -rlPz 'x-casaos:\s*\n\s*architectures:[\n\s\w-#]*- amd64\s*\n' {} \;)
amd64_count=$(find . -type f -wholename "./Apps/*.yml" -exec grep -rlPz 'x-casaos:\s*\n\s*architectures:[\n\s\w-#]*- amd64\s*\n' {} \; | wc -l)
echo "app_counts=universal($universal_count), arm($arm_count), arm64($arm64_count), amd64($amd64_count)" >> $GITHUB_OUTPUT
# Proxy get.docker.com
wget https://get.docker.com -O get_docker.sh
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload New Release
uses: softprops/action-gh-release@v2
with:
files: |
AppStore.zip
AppStore_arm.zip
AppStore_arm64.zip
AppStore_amd64.zip
tag_name: new
name: "v${{ steps.get_commit_messages.outputs.release_date }}"
draft: false
prerelease: false
body: "## What's Changed\n\n${{ steps.get_commit_messages.outputs.commits }}\n\n📊 **App Counts:** ${{ steps.create_release.outputs.app_counts }}"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload to OSS
id: upload_to_oss
uses: tvrcgo/upload-to-oss@master
with:
key-id: ${{ secrets.OSS_KEY_ID }}
key-secret: ${{ secrets.OSS_KEY_SECRET }}
endpoint: ${{ secrets.OSS_ENDPOINT }}
bucket: ${{ secrets.OSS_BUCKET }}
assets: |
AppStore.zip:Cp0204-AppStore-Play.zip
AppStore_arm.zip:Cp0204-AppStore-Play-arm.zip
AppStore_arm64.zip:Cp0204-AppStore-Play-arm64.zip
AppStore_amd64.zip:Cp0204-AppStore-Play-amd64.zip
get_docker.sh:get_docker.sh
Tools/get_casaos.sh:get_casaos.sh
Tools/casaos_newbie.sh:casaos_newbie.sh
Tools/YAML-Generator.html:generate/index.html
- name: Cloudflare Purge Cached
run: |
# Cloudflare Purge Cached
# https://developers.cloudflare.com/api/operations/zone-purge#purge-cached-content-by-url
response=$(curl --silent --request POST \
--url https://api.cloudflare.com/client/v4/zones/${{ secrets.CLOUDFLARE_ZONE_ID }}/purge_cache \
--header 'Content-Type: application/json' \
--header 'X-Auth-Email: ${{ secrets.CLOUDFLARE_EMAIL }}' \
--header 'X-Auth-Key: ${{ secrets.CLOUDFLARE_API_KEY }}' \
--data '{"purge_everything": true}')
if echo "$response" | grep -q '"success":false'; then
echo "Cloudflare Purge Cached Failed: $response"
exit 1
else
echo "Cloudflare Purge Cached Success."
fi