chore: bump to 2.9.0+20900007 #133
Workflow file for this run
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: Add Artifacts for Release | |
on: | |
workflow_dispatch: | |
inputs: | |
tag: | |
description: "Draft a release in specific tag, e.g. v1.0.0" | |
required: false | |
push: | |
tags: | |
- "v[0-9]+.[0-9]+.[0-9]+-beta" # Release only | |
jobs: | |
check-version: | |
name: Check pubspec.yaml version with tag | |
runs-on: ubuntu-latest | |
outputs: | |
tag: ${{ steps.tag.outputs.result }} | |
build_code: ${{ steps.pubspec_version.outputs.code }} | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Extract pubspec version and code | |
id: pubspec_version | |
run: | | |
ver=$(grep -m 1 '^version: ' pubspec.yaml | cut -d' ' -f2) | |
echo "version=$(echo "$ver" | cut -f1 -d"+")" >> $GITHUB_OUTPUT | |
echo "code=$(echo "$ver" | cut -f2- -d"+")" >> $GITHUB_OUTPUT | |
- name: Get tag that trigger this workflow | |
id: tag | |
uses: actions/github-script@v7 | |
with: | |
result-encoding: string | |
script: | | |
return context.eventName === 'workflow_dispatch' | |
? '${{ github.event.inputs.tag }}' | |
: context.payload.ref.replace(/\/?refs\/tags\//, '').replace(/-beta$/, ''); | |
- name: Check version | |
run: test '${{ steps.tag.outputs.result }}' = 'v${{ steps.pubspec_version.outputs.version }}' | |
# If pushing released tag (vX.X.X), it should be fired. | |
# Should build some artifacts, see below. | |
get-release: | |
name: Get release | |
runs-on: ubuntu-latest | |
needs: check-version | |
outputs: | |
changelog: ${{ steps.get_release.outputs.changelog }} | |
release_id: ${{ steps.get_release.outputs.release_id }} | |
steps: | |
# escape special characters | |
# https://github.com/actions/toolkit/issues/403 | |
- name: Get Changelog from rc1 | |
id: get_release | |
run: | | |
release=$(curl -s \ | |
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ | |
-H 'Accept: application/vnd.github.v3+json' \ | |
https://api.github.com/repos/evan361425/flutter-pos-system/releases \ | |
| jq -c '.[] | select( .name | contains("${{ needs.check-version.outputs.tag }}"))') | |
[ -z "$release" ] && exit 1 | |
{ | |
echo 'changelog<<EOF' | |
echo "$release" | jq -r '.body' | sed 's/^## //' | sed 's/^-/•/' | |
echo EOF | |
} >> "$GITHUB_OUTPUT" | |
echo "release_id=$(echo "$release" | jq -r '.id')" >> "$GITHUB_OUTPUT" | |
# Push changelog to repository | |
add-changelog: | |
name: Add changelog to Fastlane | |
runs-on: ubuntu-latest | |
needs: | |
- get-release | |
- check-version | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
ref: "master" | |
- name: Push to GitHub | |
run: | | |
file="android/fastlane/metadata/android/zh-TW/changelogs/${{ needs.check-version.outputs.build_code }}.txt" | |
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
git config --local user.name "github-actions[bot]" | |
echo "${{ needs.get-release.outputs.changelog }}" > "$file" | |
git add --all | |
git commit . -m "doc: changelog for ${{ needs.check-version.outputs.tag }}" | |
git push | |
git tag ${{ needs.check-version.outputs.tag }} | |
git push origin --tags | |
curl -X PATCH \ | |
-H 'Accept: application/vnd.github.v3+json' \ | |
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ | |
-d '{"tag_name":"${{ needs.check-version.outputs.tag }}"}' \ | |
"https://api.github.com/repos/evan361425/flutter-pos-system/releases/${{ needs.get-release.outputs.release_id }}" |