-
Notifications
You must be signed in to change notification settings - Fork 212
103 lines (101 loc) · 5.01 KB
/
deploy.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
name: Deploy
on:
pull_request:
branches:
- main
types: [closed]
env:
DEVELOPER_DIR: /Applications/Xcode_15.0.1.app
APP_VERSION: '2.7.4'
SCHEME_NAME: 'EhPanda'
ALTSTORE_JSON_PATH: './AltStore.json'
BUILDS_PATH: '/tmp/action-builds'
PAYLOAD_PATH: '/tmp/action-builds/Payload'
FILTER_SWIFT_PATH: './actions-tool/ReleaseNotesFilter.swift'
FILTER_PATH: './actions-tool/ReleaseNotesFilter'
THIN_PAYLOAD_SCRIPT_PATH: './actions-tool/thin-payload.sh'
ARCHIVE_PATH: '/tmp/action-builds/EhPanda.xcarchive'
IPA_OUTPUT_PATH: '/tmp/action-builds/EhPanda.ipa'
jobs:
Deploy:
runs-on: macos-13
if: github.event.pull_request.merged == true && github.event.pull_request.user.login == 'chihchy'
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Modify git config
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
- name: Install dependencies
run: brew install swiftgen
- name: Show Xcode version
run: xcodebuild -version
- name: Run tests
run: xcodebuild clean test -scheme ${{ env.SCHEME_NAME }} -sdk iphonesimulator
-destination 'platform=iOS Simulator,name=iPhone 15 Pro'
- name: Bump version
id: bump-version
uses: yanamura/ios-bump-version@v1
with:
version: ${{ env.APP_VERSION }}
- name: Xcode archive
run: xcodebuild archive -destination 'generic/platform=iOS'
-scheme ${{ env.SCHEME_NAME }} -archivePath ${{ env.ARCHIVE_PATH }} CODE_SIGNING_REQUIRED=NO CODE_SIGNING_ALLOWED=NO CODE_SIGN_IDENTITY= CODE_SIGN_ENTITLEMENTS= GCC_OPTIMIZATION_LEVEL=s SWIFT_OPTIMIZATION_LEVEL=-O
- name: Export .ipa file
run: |
mkdir -p ${{ env.PAYLOAD_PATH }}
mv ${{ env.ARCHIVE_PATH }}/Products/Applications/${{ env.SCHEME_NAME }}.app ${{ env.PAYLOAD_PATH }}/${{ env.SCHEME_NAME }}.app
sh ${{ env.THIN_PAYLOAD_SCRIPT_PATH }} ${{ env.PAYLOAD_PATH }}/${{ env.SCHEME_NAME }}.app
pushd ${{ env.BUILDS_PATH }}
zip -r ${{ env.IPA_OUTPUT_PATH }} ./Payload
popd
- name: Retrieve data
id: retrieve-data
run: |
swiftc -o $FILTER_PATH $FILTER_SWIFT_PATH
sudo chmod 777 $FILTER_PATH
echo "size=$(stat -f%z $IPA_OUTPUT_PATH)" >> $GITHUB_OUTPUT
echo "version_date=$(date -u +"%Y-%m-%dT%T")" >> $GITHUB_OUTPUT
echo "notes=$($FILTER_PATH "${{ github.event.pull_request.body }}")" >> $GITHUB_OUTPUT
- name: Validate data
run: |
[[ ! -z "${{ github.event.pull_request.body }}" ]] || exit 1
[[ ! -z "${{ github.event.pull_request.title }}" ]] || exit 1
[[ ! -z "${{ steps.retrieve-data.outputs.size }}" ]] || exit 1
[[ ! -z "${{ steps.retrieve-data.outputs.notes }}" ]] || exit 1
[[ ! -z "${{ steps.bump-version.outputs.version }}" ]] || exit 1
[[ ! -z "${{ steps.retrieve-data.outputs.version_date }}" ]] || exit 1
- name: Release to GitHub
uses: softprops/action-gh-release@v1
with:
fail_on_unmatched_files: true
files: ${{ env.IPA_OUTPUT_PATH }}
token: ${{ secrets.GITHUB_TOKEN }}
body: ${{ github.event.pull_request.body }}
name: ${{ github.event.pull_request.title }}
tag_name: 'v${{ steps.bump-version.outputs.version }}'
- name: Commit bump version
run: |
git add .
git commit -m "Bump version"
git push origin HEAD
- name: Update AltStore.json
run: |
echo "`jq '.apps[0].versions[0].size=${{ steps.retrieve-data.outputs.size }}' $ALTSTORE_JSON_PATH`" > $ALTSTORE_JSON_PATH
echo "`jq '.apps[0].versions[0].localizedDescription="${{ steps.retrieve-data.outputs.notes }}"' $ALTSTORE_JSON_PATH`" > $ALTSTORE_JSON_PATH
echo "`jq '.apps[0].versions[0].date="${{ steps.retrieve-data.outputs.version_date }}"' $ALTSTORE_JSON_PATH`" > $ALTSTORE_JSON_PATH
echo "`jq '.apps[0].versions[0].version="${{ steps.bump-version.outputs.version }}"' $ALTSTORE_JSON_PATH`" > $ALTSTORE_JSON_PATH
echo "`jq '.apps[0].versions[0].downloadURL="https://github.com/EhPanda-Team/EhPanda/releases/download/v${{ steps.bump-version.outputs.version }}/EhPanda.ipa"' $ALTSTORE_JSON_PATH`" > $ALTSTORE_JSON_PATH
- name: Commit update AltStore.json
run: |
git add .
git commit -m "Update AltStore.json"
git push origin HEAD
- name: Post release notes
run: |
curl https://api.telegram.org/bot${{ secrets.TELEGRAM_BOT_TOKEN }}/sendMessage \
-d parse_mode=markdown -d chat_id=${{ secrets.TELEGRAM_CHANNEL_ID }} \
-d text='*v${{ steps.bump-version.outputs.version }} Release Notes:*%0A${{ github.event.pull_request.body }}'
curl ${{ secrets.DISCORD_WEBHOOK }} \
-F 'payload_json={"content": "**v${{ steps.bump-version.outputs.version }} Release Notes:**\n${{ steps.retrieve-data.outputs.notes }}"}'