From af7a9bc093b9519ece4d0c8762e903e7ea5306bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Pacheco=20Neves?= Date: Wed, 12 May 2021 15:09:10 +0100 Subject: [PATCH] =?UTF-8?q?Unify=20Release=20and=20CI=20workflows=20?= =?UTF-8?q?=F0=9F=A4=9D=20(#236)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Unfortunately, `workflow_run` triggers only capture the branch that triggered the workflow(s) they depend on, which means that we can't use them while filtering for tag pushes (which is what we want for triggering releases). That's why `startsWith(github.ref, 'refs/tags/')` was never `true` when the `Release` workflow ran. After quite a bit of experimentation and research, I came to the conclusion that we should just keep it simple (KISS and all that 🙈) and just unify our whole CI into a single workflow which easily achieves the setup we want. Hopefully third time will be the charm to get our releases working via GitHub Actions 🍀 ## Changes - Rename `Release` workflow jobs `deploy-github` and `deploy-cocoapods` to `release-github` and `release-cocoapods` respectively. - Move release workflow jobs to the `CI` Workflow, configured to only run on tag pushes (`X.Y.Z`) and with dependencies on `build-test`, `swiftpm`, `cocoapods` and `carthage` jobs. --- .github/workflows/ci.yml | 56 ++++++++++++++++++++++++++++++-- .github/workflows/release.yml | 60 ----------------------------------- 2 files changed, 54 insertions(+), 62 deletions(-) delete mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 957684f..4f823a6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -74,7 +74,7 @@ jobs: run: swift build -Xswiftc "-sdk" -Xswiftc "`xcrun --sdk iphonesimulator --show-sdk-path`" -Xswiftc "-target" -Xswiftc "${PLATFORM_TARGET}" cocoapods: - name: CocoaPods verification + name: CocoaPods Verification runs-on: macOS-10.15 steps: - name: git checkout @@ -103,7 +103,7 @@ jobs: run: bundle exec pod lib lint carthage: - name: Carthage verification + name: Carthage Verification runs-on: macos-10.15 steps: - name: git checkout @@ -111,3 +111,55 @@ jobs: - name: carthage build run: ./script/carthage.sh build --cache-builds --no-skip-current + + release-github: + name: GitHub Release + runs-on: macOS-10.15 + needs: [build-test, swiftpm, cocoapods, carthage] + if: startsWith(github.ref, 'refs/tags/') + steps: + - name: git checkout + uses: actions/checkout@v2 + + - name: create release + uses: softprops/action-gh-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + body: | + # Changes + + - + + release-cocoapods: + name: CocoaPods Release + runs-on: macOS-10.15 + needs: [build-test, swiftpm, cocoapods, carthage] + if: startsWith(github.ref, 'refs/tags/') + steps: + - name: git checkout + uses: actions/checkout@v2 + + - name: ruby versions + run: | + ruby --version + gem --version + bundler --version + + - name: cache gems + uses: actions/cache@v2 + with: + path: vendor/bundle + key: ${{ runner.os }}-gem-${{ hashFiles('**/Gemfile.lock') }} + restore-keys: ${{ runner.os }}-gem- + + - name: bundle install + run: | + gem install bundler --no-document + bundle config path vendor/bundle + bundle install --jobs 4 --retry 3 + + - name: pod trunk push + env: + COCOAPODS_TRUNK_TOKEN: ${{ secrets.COCOAPODS_TRUNK_TOKEN }} + run: pod trunk push --allow-warnings diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml deleted file mode 100644 index 1d5f106..0000000 --- a/.github/workflows/release.yml +++ /dev/null @@ -1,60 +0,0 @@ -name: Release - -on: - workflow_run: - workflows: - - CI - types: - - completed - -jobs: - deploy-github: - name: Deploy Github - runs-on: macOS-10.15 - if: ${{ startsWith(github.ref, 'refs/tags/') && github.event.workflow_run.conclusion == 'success' }} - steps: - - name: git checkout - uses: actions/checkout@v2 - - - name: create release - uses: softprops/action-gh-release@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - body: | - # Changes - - - - - deploy-cocoapods: - name: Deploy CocoaPods - runs-on: macOS-10.15 - if: ${{ startsWith(github.ref, 'refs/tags/') && github.event.workflow_run.conclusion == 'success' }} - steps: - - name: git checkout - uses: actions/checkout@v2 - - - name: ruby versions - run: | - ruby --version - gem --version - bundler --version - - - name: cache gems - uses: actions/cache@v2 - with: - path: vendor/bundle - key: ${{ runner.os }}-gem-${{ hashFiles('**/Gemfile.lock') }} - restore-keys: ${{ runner.os }}-gem- - - - name: bundle install - run: | - gem install bundler --no-document - bundle config path vendor/bundle - bundle install --jobs 4 --retry 3 - - - name: pod trunk push - env: - COCOAPODS_TRUNK_TOKEN: ${{ secrets.COCOAPODS_TRUNK_TOKEN }} - run: pod trunk push --allow-warnings -