Fixed IAP stub in workflows (#110)

* try using script for iap stub

* typo

* typo

* typo

* removed working dir

* added comment to stub_iap.sh

* checkout first

* increment build number by script

* Update increment_build_number.sh

* fixed iap repo

* stub
This commit is contained in:
Vadim 2023-09-02 12:45:57 +02:00 committed by GitHub
parent 4bb080a144
commit da4fcfc857
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 41 additions and 30 deletions

View file

@ -0,0 +1,8 @@
export newVersion="$1"
if [[ -n "$newVersion" ]]; then
#https://stackoverflow.com/a/30214769/13167574
perl -i -pe 's/^(version:\s+)(\d+\.\d+\.\d+)(\+)(\d+)$/$1.$ENV{'newVersion'}.$3.($4+1)/e' pubspec.yaml
else
echo "argument error"
fi

2
.github/scripts/stub_iap.sh vendored Normal file
View file

@ -0,0 +1,2 @@
# https://unix.stackexchange.com/questions/435708/regex-multiline-pattern-and-substitution-replacement
perl -0777 -i -pe 's/( m3_lightmeter_iap:\n)( git:\n url: "https:\/\/github.com\/vodemn\/m3_lightmeter_iap"\n ref: main)/$1 path: iap/sg' pubspec.yaml

View file

@ -27,6 +27,10 @@ jobs:
runs-on: macos-11 runs-on: macos-11
timeout-minutes: 15 timeout-minutes: 15
steps: steps:
- uses: actions/checkout@v3
with:
submodules: recursive
- name: Connect private iap package - name: Connect private iap package
uses: webfactory/ssh-agent@v0.8.0 uses: webfactory/ssh-agent@v0.8.0
if: ${{ inputs.include-iap }} if: ${{ inputs.include-iap }}
@ -35,12 +39,7 @@ jobs:
- name: Override iap package with stub - name: Override iap package with stub
if: ${{ !inputs.include-iap }} if: ${{ !inputs.include-iap }}
run: | run: bash ./.github/scripts/stub_iap.sh
echo "\ndependency_overrides:\n m3_lightmeter_iap:\n path: iap" >> pubspec.yaml
- uses: actions/checkout@v3
with:
submodules: recursive
- uses: actions/setup-java@v2 - uses: actions/setup-java@v2
with: with:

View file

@ -46,6 +46,10 @@ jobs:
runs-on: macos-11 runs-on: macos-11
timeout-minutes: 30 timeout-minutes: 30
steps: steps:
- uses: actions/checkout@v3
with:
submodules: recursive
- name: Connect private iap package - name: Connect private iap package
uses: webfactory/ssh-agent@v0.8.0 uses: webfactory/ssh-agent@v0.8.0
if: ${{ inputs.include-iap }} if: ${{ inputs.include-iap }}
@ -54,12 +58,7 @@ jobs:
- name: Override iap package with stub - name: Override iap package with stub
if: ${{ !inputs.include-iap }} if: ${{ !inputs.include-iap }}
run: | run: bash ./.github/scripts/stub_iap.sh
echo "\ndependency_overrides:\n m3_lightmeter_iap:\n path: iap" >> pubspec.yaml
- uses: actions/checkout@v3
with:
submodules: recursive
- uses: actions/setup-java@v3 - uses: actions/setup-java@v3
with: with:
@ -98,7 +97,7 @@ jobs:
# Therefore here we have to increment it as well to build an apk with the same build number. # Therefore here we have to increment it as well to build an apk with the same build number.
- name: Increment build number & replace version number - name: Increment build number & replace version number
if: ${{ inputs.github-release }} if: ${{ inputs.github-release }}
run: perl -i -pe 's/^(version:\s+)(\d+\.\d+\.\d+)(\+)(\d+)$/$1."${{ github.event.inputs.version }}".$3.($4+1)/e' pubspec.yaml run: bash ./.github/scripts/increment_build_number.sh ${{ github.event.inputs.version }}
- name: Install Flutter - name: Install Flutter
uses: subosito/flutter-action@v2 uses: subosito/flutter-action@v2
@ -160,7 +159,7 @@ jobs:
submodules: recursive submodules: recursive
- name: Increment build number & replace version number - name: Increment build number & replace version number
run: perl -i -pe 's/^(version:\s+)(\d+\.\d+\.\d+)(\+)(\d+)$/$1."${{ github.event.inputs.version }}".$3.($4+1)/e' pubspec.yaml run: bash ./.github/scripts/increment_build_number.sh ${{ github.event.inputs.version }}
- name: Commit changes - name: Commit changes
run: | run: |

View file

@ -11,30 +11,25 @@ on:
pull_request: pull_request:
branches: ["main"] branches: ["main"]
env:
# Stub iap package if this worlflow is running from the PR from a fork
STUB_IAP: ${{ github.event.pull_request.head.repo.full_name != github.repository }}
jobs: jobs:
analyze_and_test: analyze_and_test:
name: Analyze & test name: Analyze & test
runs-on: macos-11 runs-on: macos-11
timeout-minutes: 10 timeout-minutes: 10
steps: steps:
- uses: actions/checkout@v3
with:
submodules: recursive
- name: Connect private iap package - name: Connect private iap package
uses: webfactory/ssh-agent@v0.8.0 uses: webfactory/ssh-agent@v0.8.0
if: !env.STUB_IAP if: ${{ github.event.pull_request.head.repo.full_name == github.repository }}
with: with:
ssh-private-key: ${{ secrets.M3_LIGHTMETER_IAP_KEY }} ssh-private-key: ${{ secrets.M3_LIGHTMETER_IAP_KEY }}
- name: Override iap package with stub - name: Override iap package with stub
if: env.STUB_IAP if: ${{ github.event.pull_request.head.repo.full_name != github.repository }}
run: | run: bash ./.github/scripts/stub_iap.sh
echo "\ndependency_overrides:\n m3_lightmeter_iap:\n path: iap" >> pubspec.yaml
- uses: actions/checkout@v3
with:
submodules: recursive
- uses: subosito/flutter-action@v2 - uses: subosito/flutter-action@v2
with: with:

View file

@ -1,5 +1,13 @@
enum IAPProductStatus {
purchasable,
pending,
purchased,
}
enum IAPProductType { paidFeatures } enum IAPProductType { paidFeatures }
class IAPProduct { abstract class IAPProduct {
IAPProduct(); const IAPProduct._();
IAPProductStatus get status => IAPProductStatus.purchasable;
} }

View file

@ -35,7 +35,7 @@ class IAPProducts extends InheritedModel<IAPProductType> {
super.key, super.key,
}); });
static IAPProduct? of(BuildContext context, IAPProductType type) => null; static IAPProduct? productOf(BuildContext context, IAPProductType type) => null;
static bool isPurchased(BuildContext context, IAPProductType type) => false; static bool isPurchased(BuildContext context, IAPProductType type) => false;