Skip to content

2.Draft New Release

2.Draft New Release #6

name: 2.Draft New Release
on:
workflow_dispatch:
inputs:
ipa-publish:
description: 'Publish the ipa file'
required: true
default: false
type: boolean
permissions:
contents: write
jobs:
draft-new-release:
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/master'
steps:
- name: Get Flutter Build Run ID
id: get_run_id
run: |
echo "run_id="$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" https://api.github.com/repos/${{ github.repository }}/actions/workflows/build.yml/runs | jq -r '.workflow_runs[0].id') >> "$GITHUB_OUTPUT"
- name: Download artifacts
run: |
mkdir new-build-artifacts
cd new-build-artifacts
curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" -L https://api.github.com/repos/${{ github.repository }}/actions/runs/${{ steps.get_run_id.outputs.run_id }}/artifacts | jq -r '.artifacts[].archive_download_url' | xargs -n 1 curl -LJO -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}"
echo $(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" -L https://api.github.com/repos/${{ github.repository }}/actions/runs/${{ steps.get_run_id.outputs.run_id }}/artifacts | jq -r '.artifacts[].archive_download_url')
cd ..
ls -l new-build-artifacts
- name: Unzip artifacts
run: |
unzip -o 'new-build-artifacts/*.zip' -d new-build-artifacts
ls -l new-build-artifacts
- name: Get Git info
id: get_git_info
run: |
echo "RESOLVED_VERSION="$(ls new-build-artifacts | grep -oP 'SITLife-v\d+\.\d+\.\d+\+\d+' | head -n 1 | cut -d'-' -f2) >> "$GITHUB_OUTPUT"
echo "PREVIOUS_TAG="$(curl -s https://api.github.com/repos/${{ github.repository }}/releases/latest | jq -r '.tag_name') >> "$GITHUB_OUTPUT"
- name: Check builds
id: builds
env:
RESOLVED_VERSION: ${{ steps.get_git_info.outputs.RESOLVED_VERSION }}
run: |
if [ "${{ github.event.inputs.ipa-publish }}" == "false" ]; then
rm -rf new-build-artifacts/SITLife-${{ env.RESOLVED_VERSION }}.ipa
fi
if [ ! -f "new-build-artifacts/SITLife-${{ env.RESOLVED_VERSION }}.apk" ]; then
echo "APK_SHA256=" >> "$GITHUB_OUTPUT"
else
echo "APK_SHA256=- \`SITLife-${{ env.RESOLVED_VERSION }}.apk\`: "$(sha256sum new-build-artifacts/SITLife-${{ env.RESOLVED_VERSION }}.apk | awk '{print $1}') >> "$GITHUB_OUTPUT"
fi
if [ ! -f "new-build-artifacts/SITLife-${{ env.RESOLVED_VERSION }}.ipa" ]; then
echo "IPA_SHA256=" >> "$GITHUB_OUTPUT"
else
echo "IPA_SHA256=- \`SITLife-${{ env.RESOLVED_VERSION }}.ipa\`: "$(sha256sum new-build-artifacts/SITLife-${{ env.RESOLVED_VERSION }}.ipa | awk '{print $1}') >> "$GITHUB_OUTPUT"
fi
- name: Print path of builds
run: |
ls -a new-build-artifacts
- name: Release
uses: softprops/action-gh-release@v2
env:
RESOLVED_VERSION: ${{ steps.get_git_info.outputs.RESOLVED_VERSION }}
PREVIOUS_TAG: ${{ steps.get_git_info.outputs.PREVIOUS_TAG }}
with:
files: |
new-build-artifacts/SITLife-${{ env.RESOLVED_VERSION }}.apk
new-build-artifacts/SITLife-${{ env.RESOLVED_VERSION }}.ipa
tag_name: ${{ env.RESOLVED_VERSION }}
body: |
## Changes
### Features
- Foo
### Bug fixes
- Bar
## 更改
### 新功能
- Foo
### Bug 修复
- Bar
## How to download
<!-- Android:main -->
<!-- - `Android`: Click the .apk files below.-->
<!-- iOS:main -->
<!-- - `iOS`: [Download on the App Store](https://apps.apple.com/cn/app/id6468989112).-->
<!-- iOS:TestFlight -->
<!-- - `iOS`: [Join the Test Flight](https://testflight.apple.com/join/ecafeulK).-->
<!-- iOS:Debug -->
<!-- - `iOS`: Click the .ipa files below.-->
- `Android`: Click the .apk files below.
- `iOS`: [Download on the App Store](https://apps.apple.com/cn/app/id6468989112).
## Checksum (sha256)
${{ steps.builds.outputs.APK_SHA256 }}
${{ steps.builds.outputs.IPA_SHA256 }}
Full Changelog: https://github.com/${{ github.repository }}/compare/${{ env.PREVIOUS_TAG }}...${{ env.RESOLVED_VERSION }}
draft: true
prerelease: false