Skip to content

Commit

Permalink
Improve version generation
Browse files Browse the repository at this point in the history
  • Loading branch information
cachapa committed Nov 29, 2023
1 parent cd843ca commit f0a206f
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,3 @@ jobs:
- uses: subosito/flutter-action@v1
- run: echo "${{ secrets.CONFIG }}" > lib/config.dart
- run: flutter analyze

39 changes: 32 additions & 7 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,36 +13,61 @@ on:

jobs:
version:
name: Generate version
runs-on: ubuntu-latest
outputs:
name: ${{ steps.name.outputs.name }}
name: ${{ steps.version.outputs.name }}
number: ${{ steps.version.outputs.number }}
steps:
- name: checkout
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: read-yaml-file
- name: Read version from pubspec
uses: pietrobolcato/action-read-yaml@1.1.0
id: yaml
id: pubspec
with:
config: pubspec.yaml

- id: name
run: echo "name=`echo ${{ steps.yaml.outputs['version'] }} | sed 's/[0-9]*$/${{ github.run_number }}/'`" >> $GITHUB_OUTPUT
- name: Get latest version
id: latest
uses: WyriHaximus/github-action-get-previous-tag@v1

android:
- name: Parse latest version
id: parser
uses: booxmedialtd/ws-action-parse-semver@v1.4.7
with:
input_string: ${{ steps.latest.outputs.tag }}

- name: Generate version
id: version
env:
yaml: ${{ steps.yaml.outputs.version }}
release: ${{ steps.latest.outputs.tag }}
major: ${{ steps.parser.outputs.major }}
minor: ${{ steps.parser.outputs.minor }}
patch: ${{ steps.parser.outputs.patch }}
run: |
next=`expr $patch + 1`
v=`[[ $yaml > $release ]] && echo $yaml || echo "$major.$minor.$next"`
echo "name=$v" >> $GITHUB_OUTPUT
echo "number=`expr $GITHUB_RUN_NUMBER + 70`" >> $GITHUB_OUTPUT
Android:
if: inputs.android
uses: ./.github/workflows/release_android.yml
needs: version
secrets: inherit
with:
name: "${{ needs.version.outputs.name }}"
number: "${{ needs.version.outputs.number }}"

ios:
iOS:
if: inputs.ios
uses: ./.github/workflows/release_ios.yml
needs: version
secrets: inherit
with:
name: "${{ needs.version.outputs.name }}"
number: "${{ needs.version.outputs.number }}"
21 changes: 13 additions & 8 deletions .github/workflows/release_android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,27 @@ on:
name:
required: true
type: string
number:
required: true
type: string

concurrency:
group: "release_android"
cancel-in-progress: true

jobs:
build:
timeout-minutes: 25
timeout-minutes: 30
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/checkout@v4

- uses: actions/setup-java@v1
- uses: actions/setup-java@v3
with:
java-version: '12.x'
distribution: 'temurin'
java-version: '17'
cache: 'gradle'

- uses: subosito/flutter-action@v2

Expand All @@ -39,8 +42,8 @@ jobs:
- name: Build app
env:
BUILD_NAME: ${{ inputs.name }}
BUILD_NUMBER: ${{ inputs.number }}
run: |
BUILD_NUMBER=`expr $GITHUB_RUN_NUMBER + 70`
flutter build appbundle --build-number $BUILD_NUMBER --build-name $BUILD_NAME
flutter build apk --build-number $BUILD_NUMBER --build-name $BUILD_NAME
Expand All @@ -50,7 +53,9 @@ jobs:
tag_name: ${{ inputs.name }}
name: "tudo ${{ inputs.name }}"
generate_release_notes: true
files: build/app/outputs/apk/release/app-release.apk
files: |
build/app/outputs/apk/release/app-release.arb
build/app/outputs/apk/release/app-release.apk
- name: Publish Android
uses: r0adkll/upload-google-play@v1
Expand Down
12 changes: 7 additions & 5 deletions .github/workflows/release_ios.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,21 @@ on:
name:
required: true
type: string
number:
required: true
type: string

concurrency:
group: "release_ios"
cancel-in-progress: true

jobs:
build:
timeout-minutes: 25
timeout-minutes: 30
runs-on: macos-latest

steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/checkout@v4

- name: Import signing certificate
env:
Expand All @@ -41,7 +42,8 @@ jobs:
- name: Build app
env:
BUILD_NAME: ${{ inputs.name }}
run: flutter build ipa --export-options-plist=.github/provisioning/ExportOptions.plist --build-number $GITHUB_RUN_NUMBER --build-name $BUILD_NAME
BUILD_NUMBER: ${{ inputs.number }}
run: flutter build ipa --export-options-plist=.github/provisioning/ExportOptions.plist --build-number $BUILD_NUMBER --build-name $BUILD_NAME

- name: Upload app to App Store Connect
env:
Expand Down

0 comments on commit f0a206f

Please sign in to comment.