From 287847e1c20bc979da6b71b29aa3300bdbc22be8 Mon Sep 17 00:00:00 2001 From: McCabe Coats Date: Tue, 9 May 2023 15:13:08 -0600 Subject: [PATCH] Simplify generate sdk workflow Our `publish` and `release` workflows run when we `push` to `master` so we can remove the `publish` and `release` jobs from our repository dispatch `generate_sdk` workflow. This should also fix any issues we are seeing where we are trying to publish or release using the wrong version. The old version seems to have been cached during the old flow which caused the workflow to fail. --- .../workflows/generate_publish_release.yml | 121 ------------------ .github/workflows/generate_sdk.yml | 56 ++++++++ 2 files changed, 56 insertions(+), 121 deletions(-) delete mode 100644 .github/workflows/generate_publish_release.yml create mode 100644 .github/workflows/generate_sdk.yml diff --git a/.github/workflows/generate_publish_release.yml b/.github/workflows/generate_publish_release.yml deleted file mode 100644 index 7e32aeb..0000000 --- a/.github/workflows/generate_publish_release.yml +++ /dev/null @@ -1,121 +0,0 @@ -name: Generate Publish Release - -on: - repository_dispatch: - types: [generate_publish_release] - -jobs: - Generate: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - uses: actions/setup-node@v3 - - uses: ruby/setup-ruby@v1 - with: - ruby-version: 3.1 - - name: Bump version - id: bump_version - run: echo "::set-output name=version::$(ruby .github/version.rb ${{ github.event.client_payload.version }})" - - name: Clean repo - run: ruby .github/clean.rb - - name: Install openapi-generator-cli - run: | - npm install @openapitools/openapi-generator-cli -g - openapi-generator-cli version-manager set 5.4.0 - - run: | - openapi-generator-cli generate \ - -i https://raw.githubusercontent.com/mxenabled/openapi/master/openapi/mx_platform_api.yml \ - -g ruby \ - -c ./openapi/config.yml \ - -t ./openapi/templates - - name: Checkout master - run: git checkout master - - name: Create commit - run: | - git config user.name "devexperience" - git config user.email "devexperience@mx.com" - git add . - git commit -m "Generated version ${{ steps.bump_version.outputs.version }} - - This commit was automatically created by a GitHub Action to generate version ${{ steps.bump_version.outputs.version }} of this library." - - name: Push to master - run: git push origin master - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - name: Slack notification - uses: ravsamhq/notify-slack-action@v2 - if: always() - with: - status: ${{ job.status }} - token: ${{ secrets.GITHUB_TOKEN }} - notification_title: "{repo}: {workflow} workflow" - message_format: "{emoji} *{workflow}* {status_message} in <{repo_url}|{repo}>" - footer: "<{workflow_url}|View Workflow>" - notify_when: "failure" - env: - SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} - Publish: - runs-on: ubuntu-latest - needs: Generate - permissions: - packages: write - contents: read - steps: - - uses: actions/checkout@v3 - - name: Set up Ruby - uses: ruby/setup-ruby@v1 - with: - ruby-version: 2.6 - - run: bundle install - - name: Publish to RubyGems - run: | - mkdir -p $HOME/.gem - touch $HOME/.gem/credentials - chmod 0600 $HOME/.gem/credentials - printf -- "---\n:rubygems_api_key: ${RUBY_GEMS_API_KEY}\n" > $HOME/.gem/credentials - gem build *.gemspec - gem push *.gem - env: - RUBY_GEMS_API_KEY: "${{ secrets.RUBYGEMS_AUTH_TOKEN }}" - - name: Slack notification - uses: ravsamhq/notify-slack-action@v2 - if: always() - with: - status: ${{ job.status }} - token: ${{ secrets.GITHUB_TOKEN }} - notification_title: "{repo}: {workflow} workflow" - message_format: "{emoji} *{workflow}* {status_message} in <{repo_url}|{repo}>" - footer: "<{workflow_url}|View Workflow>" - notify_when: "failure" - env: - SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} - Release: - runs-on: ubuntu-latest - needs: Publish - steps: - - uses: actions/checkout@v3 - - name: Set up Ruby - uses: ruby/setup-ruby@v1 - with: - bundler-cache: true - ruby-version: 3.1 - - name: Read version - id: read_version - run: echo "::set-output name=version::$(ruby .github/version.rb)" - - name: Create tag and release - run: | - gh release create "v${{ steps.read_version.outputs.version }}" - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - name: Slack notification - uses: ravsamhq/notify-slack-action@v2 - if: always() - with: - status: ${{ job.status }} - token: ${{ secrets.GITHUB_TOKEN }} - notification_title: "{repo}: {workflow} workflow" - message_format: "{emoji} *{workflow}* {status_message} in <{repo_url}|{repo}>" - footer: "<{workflow_url}|View Workflow>" - notify_when: "failure" - env: - SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} diff --git a/.github/workflows/generate_sdk.yml b/.github/workflows/generate_sdk.yml new file mode 100644 index 0000000..82803a9 --- /dev/null +++ b/.github/workflows/generate_sdk.yml @@ -0,0 +1,56 @@ +name: Generate SDK + +on: + repository_dispatch: + types: [generate_sdk] + +jobs: + Generate: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + - uses: ruby/setup-ruby@v1 + with: + ruby-version: 3.1 + - name: Bump version + id: bump_version + run: echo "::set-output name=version::$(ruby .github/version.rb ${{ github.event.client_payload.version }})" + - name: Clean repo + run: ruby .github/clean.rb + - name: Install openapi-generator-cli + run: | + npm install @openapitools/openapi-generator-cli -g + openapi-generator-cli version-manager set 5.4.0 + - run: | + openapi-generator-cli generate \ + -i https://raw.githubusercontent.com/mxenabled/openapi/master/openapi/mx_platform_api.yml \ + -g ruby \ + -c ./openapi/config.yml \ + -t ./openapi/templates + - name: Checkout master + run: git checkout master + - name: Create commit + run: | + git config user.name "devexperience" + git config user.email "devexperience@mx.com" + git add . + git commit -m "Generated version ${{ steps.bump_version.outputs.version }} + + This commit was automatically created by a GitHub Action to generate version ${{ steps.bump_version.outputs.version }} of this library." + - name: Push to master + run: git push origin master + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Slack notification + uses: ravsamhq/notify-slack-action@v2 + if: always() + with: + status: ${{ job.status }} + token: ${{ secrets.GITHUB_TOKEN }} + notification_title: "{repo}: {workflow} workflow" + message_format: "{emoji} *{workflow}* {status_message} in <{repo_url}|{repo}>" + footer: "<{workflow_url}|View Workflow>" + notify_when: "failure" + env: + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}