Skip to content

chore: bump to 2.10.0+21000003 #138

chore: bump to 2.10.0+21000003

chore: bump to 2.10.0+21000003 #138

Workflow file for this run

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]+" # 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\//, '');
- 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/%s/changelogs/${{ needs.check-version.outputs.build_code }}.txt'
printf "Source file: $file\n" "en-US"
printf '%s\n' "$(cat <<EOF
${{ needs.get-release.outputs.changelog }}
EOF
)" > $(printf "$file" "en-US")
bash android/fastlane/translate-changelog.sh "$file" '${{ secrets.GOOGLE_AI_API_KEY }}'
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git add --all
git commit . -m "doc: changelog for ${{ needs.check-version.outputs.tag }}"
git push
# Replace the tag to reference the most recent commit
git tag -f ${{ needs.check-version.outputs.tag }}
git push -f origin --tags
# Update release tag name for later deploy to playstore
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 }}"