-
Couldn't load subscription status.
- Fork 813
chore: configure workflows for Flutter app #2562
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| name: "Android Workflow" | ||
|
|
||
| inputs: | ||
| STORE_PASS: | ||
| description: 'Store Password' | ||
| required: false | ||
| default: '' | ||
| ALIAS: | ||
| description: 'Certificate Alias' | ||
| required: false | ||
| default: '' | ||
| KEY_PASS: | ||
| description: 'Key Password' | ||
| required: false | ||
| default: '' | ||
| VERSION_NAME: | ||
| description: 'Version Name to be used for build' | ||
| required: false | ||
| default: '1.0.0' | ||
| VERSION_CODE: | ||
| description: 'Version Code to be used for build' | ||
| required: true | ||
AsCress marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| default: '1' | ||
|
|
||
| runs: | ||
| using: "composite" | ||
| steps: | ||
| - name: Set up Java | ||
| uses: actions/setup-java@v2 | ||
| with: | ||
| java-version: 17 | ||
| distribution: 'adopt' | ||
| cache: 'gradle' | ||
|
|
||
| - name: Set up Flutter | ||
| uses: subosito/flutter-action@v2 | ||
| with: | ||
| cache: true | ||
|
|
||
| - name: Build Android APK/AAB | ||
| shell: bash | ||
| env: | ||
| STORE_PASS: ${{ inputs.STORE_PASS }} | ||
| ALIAS: ${{ inputs.ALIAS }} | ||
| KEY_PASS: ${{ inputs.KEY_PASS }} | ||
| VERSION_NAME: ${{inputs.VERSION_NAME}} | ||
| VERSION_CODE: ${{inputs.VERSION_CODE}} | ||
| run: | | ||
| flutter build apk --build-name $VERSION_NAME --build-number $VERSION_CODE | ||
| flutter build appbundle --build-name $VERSION_NAME --build-number $VERSION_CODE | ||
|
|
||
| - name: Store APK file | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: apk-files | ||
| path: | | ||
| build/app/outputs/flutter-apk | ||
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| name: "Common Workflow" | ||
|
|
||
| runs: | ||
| using: "composite" | ||
| steps: | ||
| - name: Set up Flutter | ||
| uses: subosito/flutter-action@v2 | ||
| with: | ||
| cache: true | ||
|
|
||
| - name: Fetch Flutter Dependencies | ||
| shell: bash | ||
| run: flutter pub get | ||
|
|
||
| - name: Validate Code Format | ||
| shell: bash | ||
| run: dart format --output=none --set-exit-if-changed . | ||
|
|
||
| - name: Analyze Code | ||
| shell: bash | ||
| run: flutter analyze | ||
|
|
||
| - name: Run tests | ||
| shell: bash | ||
| run: flutter test |
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| name: "iOS Workflow" | ||
|
|
||
| inputs: | ||
| VERSION_NAME: | ||
| description: 'Version Name to be used for build' | ||
| required: false | ||
| default: '1.0.0' | ||
| VERSION_CODE: | ||
| description: 'Version Code to be used for build' | ||
| required: true | ||
| default: '1' | ||
|
|
||
| runs: | ||
| using: "composite" | ||
| steps: | ||
| - name: Set up Flutter | ||
| uses: subosito/flutter-action@v2 | ||
| with: | ||
| cache: true | ||
|
|
||
| - name: Build iOS IPA | ||
| shell: bash | ||
| env: | ||
| VERSION_NAME: ${{inputs.VERSION_NAME}} | ||
| VERSION_CODE: ${{inputs.VERSION_CODE}} | ||
| run: | | ||
| flutter build ipa --no-codesign --build-name $VERSION_NAME --build-number $VERSION_CODE |
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,128 @@ | ||
| name: Comment | ||
|
|
||
| on: | ||
| workflow_run: | ||
| workflows: [ Build ] | ||
| types: | ||
| - completed | ||
|
|
||
| jobs: | ||
| comment: | ||
| runs-on: ubuntu-latest | ||
| if: > | ||
| github.event.workflow_run.event == 'pull_request' | ||
| steps: | ||
| - name: Download artifact | ||
| uses: actions/github-script@v7 | ||
| with: | ||
| script: | | ||
| var artifacts = await github.rest.actions.listWorkflowRunArtifacts({ | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| run_id: ${{github.event.workflow_run.id }}, | ||
| }); | ||
| var matchArtifact = artifacts.data.artifacts.filter((artifact) => { | ||
| return artifact.name == "pr" | ||
| })[0]; | ||
| var download = await github.rest.actions.downloadArtifact({ | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| artifact_id: matchArtifact.id, | ||
| archive_format: 'zip', | ||
| }); | ||
| var fs = require('fs'); | ||
| fs.writeFileSync('${{github.workspace}}/pr.zip', Buffer.from(download.data)); | ||
| - run: unzip pr.zip | ||
|
|
||
| - name: Build success | ||
| if: ${{ github.event.workflow_run.conclusion == 'success' }} | ||
| uses: actions/github-script@v7 | ||
| with: | ||
| script: | | ||
| var fs = require('fs') | ||
| var issue_number = Number(fs.readFileSync('./NR')); | ||
| const owner = context.repo.owner; | ||
| const repo = context.repo.repo; | ||
| var artifacts = await github.rest.actions.listWorkflowRunArtifacts({ | ||
| owner, | ||
| repo, | ||
| run_id: ${{github.event.workflow_run.id }}, | ||
| }); | ||
| var matchArtifact = artifacts.data.artifacts.filter((artifact) => { | ||
| return artifact.name == "apk-files" | ||
| })[0]; | ||
| const artifact_url = `https://github.com/${owner}/${repo}/actions/runs/${{ github.event.workflow_run.id }}/artifacts/${matchArtifact.id}`; | ||
|
|
||
| const comments = await github.rest.issues.listComments({ | ||
| owner, | ||
| repo, | ||
| issue_number | ||
| }); | ||
|
|
||
| let comment_id; | ||
| for (const comment of comments.data) { | ||
| if (comment.user.login === 'github-actions[bot]') { | ||
| comment_id = comment.id; | ||
| break; | ||
| } | ||
| } | ||
|
|
||
| const body = `Build successful. APKs to test: ${artifact_url}`; | ||
|
|
||
| if (comment_id) { | ||
| await github.rest.issues.updateComment({ | ||
| owner, | ||
| repo, | ||
| comment_id, | ||
| body | ||
| }); | ||
| } else { | ||
| await github.rest.issues.createComment({ | ||
| owner, | ||
| repo, | ||
| issue_number, | ||
| body | ||
| }); | ||
| } | ||
|
|
||
| - name: Build failed | ||
| if: ${{ github.event.workflow_run.conclusion == 'failure' }} | ||
| uses: actions/github-script@v7 | ||
| with: | ||
| script: | | ||
| var fs = require('fs') | ||
| var issue_number = Number(fs.readFileSync('./NR')); | ||
| const owner = context.repo.owner; | ||
| const repo = context.repo.repo; | ||
|
|
||
| const comments = await github.rest.issues.listComments({ | ||
| owner, | ||
| repo, | ||
| issue_number | ||
| }); | ||
|
|
||
| let comment_id; | ||
| for (const comment of comments.data) { | ||
| if (comment.user.login === 'github-actions[bot]') { | ||
| comment_id = comment.id; | ||
| break; | ||
| } | ||
| } | ||
|
|
||
| const body = `Build failed`; | ||
|
|
||
| if (comment_id) { | ||
| await github.rest.issues.updateComment({ | ||
| owner, | ||
| repo, | ||
| comment_id, | ||
| body | ||
| }); | ||
| } else { | ||
| await github.rest.issues.createComment({ | ||
| owner, | ||
| repo, | ||
| issue_number, | ||
| body | ||
| }); | ||
| } |
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| name: Build | ||
|
|
||
| on: | ||
| pull_request: | ||
| branches: ["flutter"] | ||
|
|
||
| jobs: | ||
| common: | ||
| name: Common Build | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| - name: Common Workflow | ||
| uses: ./.github/actions/common | ||
|
|
||
| - name: Save PR number | ||
| run: | | ||
| mkdir -p ./pr | ||
| echo ${{ github.event.number }} > ./pr/NR | ||
|
|
||
| - uses: actions/upload-artifact@v3 | ||
| with: | ||
| name: pr | ||
| path: pr/ | ||
|
|
||
| android: | ||
| name: Android Flutter Build | ||
| needs: common | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| - name: Android Workflow | ||
| uses: ./.github/actions/android | ||
|
|
||
| ios: | ||
| name: iOS Flutter Build | ||
| needs: common | ||
| runs-on: macos-latest | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| - name: iOS Workflow | ||
| uses: ./.github/actions/ios |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.