From b6111fa88919b94a348422f9ac88d4f452337e69 Mon Sep 17 00:00:00 2001 From: Bram De Coninck Date: Wed, 11 Sep 2024 17:37:22 +0200 Subject: [PATCH] Get rid of duplicate code --- .../actions/prepare-macos-runner/action.yaml | 23 +++++++ .../actions/prepare-ubuntu-runner/action.yaml | 21 ++++++ ...ult-workflow.yml => default-workflow.yaml} | 56 +++------------- .github/workflows/release-workflow.yaml | 67 +++---------------- 4 files changed, 66 insertions(+), 101 deletions(-) create mode 100644 .github/actions/prepare-macos-runner/action.yaml create mode 100644 .github/actions/prepare-ubuntu-runner/action.yaml rename .github/workflows/{default-workflow.yml => default-workflow.yaml} (50%) diff --git a/.github/actions/prepare-macos-runner/action.yaml b/.github/actions/prepare-macos-runner/action.yaml new file mode 100644 index 0000000..e6fefa5 --- /dev/null +++ b/.github/actions/prepare-macos-runner/action.yaml @@ -0,0 +1,23 @@ +name: "Prepare macOS runner" +description: "Prepare macOS runner" +runs: + using: "composite" + steps: + - name: Set up Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: "3.1.1" # TODO: keep this somewhere where it's easy to change + + - name: Install gems + shell: bash + run: bundle install + + - name: Install FVM + shell: bash + run: | + brew tap leoafarias/fvm + brew install fvm + + - name: Set up FVM + shell: bash + run: fvm use \ No newline at end of file diff --git a/.github/actions/prepare-ubuntu-runner/action.yaml b/.github/actions/prepare-ubuntu-runner/action.yaml new file mode 100644 index 0000000..88144fa --- /dev/null +++ b/.github/actions/prepare-ubuntu-runner/action.yaml @@ -0,0 +1,21 @@ +name: "Prepare Ubuntu runner" +description: "Prepare Ubuntu runner" +runs: + using: "composite" + steps: + - name: Set up Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: "3.1.1" # TODO: keep this somewhere where it's easy to change + + - name: Install gems + shell: bash + run: bundle install + + - name: Install FVM + shell: bash + run: curl -fsSL https://fvm.app/install.sh | bash + + - name: Set up FVM + shell: bash + run: fvm use \ No newline at end of file diff --git a/.github/workflows/default-workflow.yml b/.github/workflows/default-workflow.yaml similarity index 50% rename from .github/workflows/default-workflow.yml rename to .github/workflows/default-workflow.yaml index 75b87ba..46f52e2 100644 --- a/.github/workflows/default-workflow.yml +++ b/.github/workflows/default-workflow.yaml @@ -1,8 +1,9 @@ name: default-workflow -on: - push: - branches: - - main +on: [push] +# on: +# push: +# branches: +# - main jobs: test: name: Run tests @@ -10,19 +11,8 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Set up Ruby - uses: ruby/setup-ruby@v1 - with: - ruby-version: "3.1.1" # TODO: keep this somewhere where it's easy to change - - - name: Install gems - run: bundle install - - - name: Install FVM - run: curl -fsSL https://fvm.app/install.sh | bash - - - name: Set up FVM - run: fvm use + - name: Prepare runner + uses: ./.github/actions/prepare-ubuntu-runner - name: Run virtual machine tests run: bundle exec fastlane run_vm_tests @@ -34,19 +24,8 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Set up Ruby - uses: ruby/setup-ruby@v1 - with: - ruby-version: "3.1.1" # TODO: keep this somewhere where it's easy to change - - - name: Install gems - run: bundle install - - - name: Install FVM - run: curl -fsSL https://fvm.app/install.sh | bash - - - name: Set up FVM - run: fvm use + - name: Prepare runner + uses: ./.github/actions/prepare-ubuntu-runner - name: Decode and save google-services.json run: echo "${{ secrets.GOOGLE_SERVICES_JSON }}" | base64 -d > ./android/app/google-services.json @@ -67,21 +46,8 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Set up Ruby - uses: ruby/setup-ruby@v1 - with: - ruby-version: "3.1.1" # TODO: keep this somewhere where it's easy to change - - - name: Install gems - run: bundle install - - - name: Install FVM - run: | - brew tap leoafarias/fvm - brew install fvm - - - name: Set up FVM - run: fvm use + - name: Prepare runner + uses: ./.github/actions/prepare-macos-runner - name: Decode and save GoogleServices-Info.plist run: echo "${{ secrets.GOOGLESERVICE_INFO_PLIST }}" | base64 -d > ./ios/Runner/GoogleService-Info.plist diff --git a/.github/workflows/release-workflow.yaml b/.github/workflows/release-workflow.yaml index c307356..a05782f 100644 --- a/.github/workflows/release-workflow.yaml +++ b/.github/workflows/release-workflow.yaml @@ -12,19 +12,8 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Set up Ruby - uses: ruby/setup-ruby@v1 - with: - ruby-version: "3.1.1" # TODO: keep this somewhere where it's easy to change - - - name: Install gems - run: bundle install - - - name: Install FVM - run: curl -fsSL https://fvm.app/install.sh | bash - - - name: Set up FVM - run: fvm use + - name: Prepare runner + uses: ./.github/actions/prepare-ubuntu-runner - name: Run virtual machine tests run: bundle exec fastlane run_vm_tests @@ -36,19 +25,8 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Set up Ruby - uses: ruby/setup-ruby@v1 - with: - ruby-version: "3.1.1" # TODO: keep this somewhere where it's easy to change - - - name: Install gems - run: bundle install - - - name: Install FVM - run: curl -fsSL https://fvm.app/install.sh | bash - - - name: Set up FVM - run: fvm use + - name: Prepare runner + uses: ./.github/actions/prepare-ubuntu-runner - name: Decode and save google-services.json run: echo "${{ secrets.GOOGLE_SERVICES_JSON }}" | base64 -d > ./android/app/google-services.json @@ -81,21 +59,8 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Set up Ruby - uses: ruby/setup-ruby@v1 - with: - ruby-version: "3.1.1" # TODO: keep this somewhere where it's easy to change - - - name: Install gems - run: bundle install - - - name: Install FVM - run: | - brew tap leoafarias/fvm - brew install fvm - - - name: Set up FVM - run: fvm use + - name: Prepare runner + uses: ./.github/actions/prepare-macos-runner - name: Decode and save GoogleServices-Info.plist run: echo "${{ secrets.GOOGLESERVICE_INFO_PLIST }}" | base64 -d > ./ios/Runner/GoogleService-Info.plist @@ -132,13 +97,8 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Set up Ruby - uses: ruby/setup-ruby@v1 - with: - ruby-version: "3.1.1" # TODO: keep this somewhere where it's easy to change - - - name: Install gems - run: bundle install + - name: Prepare runner + uses: ./.github/actions/prepare-ubuntu-runner - name: Decode and save Firebase App Distribution service account run: echo "${{ secrets.FIREBASE_APP_DISTRIBUTION_SERVICE_ACCOUNT_JSON }}" | base64 -d > ./FIREBASE_APP_DISTRIBUTION_SERVICE_ACCOUNT.json @@ -154,18 +114,13 @@ jobs: distribute_ios: name: Distribute iOS release - runs-on: macos-latest + runs-on: ubuntu-latest needs: [build_android, build_ios] steps: - uses: actions/checkout@v4 - - name: Set up Ruby - uses: ruby/setup-ruby@v1 - with: - ruby-version: "3.1.1" # TODO: keep this somewhere where it's easy to change - - - name: Install gems - run: bundle install + - name: Prepare runner + uses: ./.github/actions/prepare-ubuntu-runner - name: Decode and save Firebase App Distribution service account run: echo "${{ secrets.FIREBASE_APP_DISTRIBUTION_SERVICE_ACCOUNT_JSON }}" | base64 -d > ./FIREBASE_APP_DISTRIBUTION_SERVICE_ACCOUNT.json