Bugfix #220
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Deploy | |
on: | |
pull_request: | |
branches: | |
- main | |
types: [closed] | |
env: | |
DEVELOPER_DIR: /Applications/Xcode_16.1.app | |
APP_VERSION: '2.7.8' | |
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-15 | |
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: Show Xcode version | |
run: xcodebuild -version | |
- name: Run tests | |
run: xcodebuild clean test | |
-skipMacroValidation | |
-scheme ${{ env.SCHEME_NAME }} | |
-destination 'platform=iOS Simulator,name=iPhone 16 Pro' | |
- name: Bump version | |
id: bump-version | |
uses: yanamura/ios-bump-version@v1 | |
with: | |
version: ${{ env.APP_VERSION }} | |
- name: Xcode archive | |
run: xcodebuild archive | |
-skipMacroValidation | |
-scheme ${{ env.SCHEME_NAME }} | |
-destination 'generic/platform=iOS' | |
-archivePath ${{ env.ARCHIVE_PATH }} | |
CODE_SIGN_IDENTITY= | |
CODE_SIGN_ENTITLEMENTS= | |
CODE_SIGNING_ALLOWED=NO | |
CODE_SIGNING_REQUIRED=NO | |
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@v2 | |
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 }}"}' |