Publish beta OAS with monthly pre-release minor version update #218
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
| name: Publish beta OAS with monthly pre-release minor version update | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| override_schedule: | |
| description: "Override the release schedule?" | |
| required: true | |
| type: boolean | |
| default: false | |
| schedule: | |
| - cron: '0 12 * * 3' | |
| jobs: | |
| check: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| should-continue: ${{ steps.checker.outputs.continue }} | |
| steps: | |
| - name: Check if it is first Wednesday of the month | |
| id: checker | |
| continue-on-error: true | |
| run: | | |
| if [[ `date +'%d' | sed 's/^0*//'` -le 7 ]]; then | |
| echo "continue=yes" >> $GITHUB_OUTPUT | |
| else | |
| echo "continue=no" >> $GITHUB_OUTPUT | |
| fi | |
| publish: | |
| needs: check | |
| if: inputs.override_schedule || needs.check.outputs.should-continue == 'yes' | |
| runs-on: ubuntu-latest | |
| permissions: | |
| id-token: write | |
| contents: write | |
| steps: | |
| - uses: actions/checkout@master | |
| with: | |
| ref: "v1-beta" | |
| - name: Configure AWS credentials | |
| uses: aws-actions/configure-aws-credentials@v4 | |
| with: | |
| role-to-assume: arn:aws:iam::469746060910:role/github-openapi-s3-download | |
| aws-region: us-west-2 | |
| - name: Read from AWS bucket | |
| run: | | |
| aws s3 sync s3://meraki-api-oas ./openapi | |
| mv openapi/oas2_beta.json openapi/spec2.json | |
| mv openapi/oas3_beta.json openapi/spec3.json | |
| rm openapi/oas*_ga.json | |
| - name: Get latest pre-release version | |
| id: current-version | |
| uses: cardinalby/git-get-release-action@v1 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| with: | |
| latest: true | |
| prerelease: true | |
| - name: Strip v prefix from version | |
| id: sanitized-prefix | |
| run: | | |
| CURRENT_VERSION=${{ steps.current-version.outputs.tag_name }} | |
| VERSION_WITHOUT_V=$(echo $CURRENT_VERSION | sed -e "s/v//gI") | |
| echo "SANITIZED_PREFIX=$VERSION_WITHOUT_V" >> $GITHUB_OUTPUT | |
| - name: Generate next version | |
| id: next-version | |
| uses: HardNorth/github-version-generate@v1.3.0 | |
| with: | |
| version: ${{ steps.sanitized-prefix.outputs.SANITIZED_PREFIX }} | |
| next-version-increment-minor: true | |
| - name: Set new version | |
| id: new-version | |
| run: echo "NEW_VERSION=v${{ env.CURRENT_VERSION_MAJOR }}.${{ env.NEXT_VERSION_MINOR }}.0-beta.0" >> $GITHUB_ENV | |
| - name: Update OAS docs with new version | |
| uses: jacobtomlinson/gha-find-replace@v2 | |
| with: | |
| find: '"version": "0.0.0"' | |
| replace: '"version": "${{ env.CURRENT_VERSION_MAJOR }}.${{ env.NEXT_VERSION_MINOR }}.0-beta.0"' | |
| regex: false | |
| include: openapi/* | |
| - name: Commit changes | |
| uses: EndBug/add-and-commit@v9 | |
| with: | |
| add: openapi/* | |
| new_branch: "v1-beta" | |
| tag: "${{ env.NEW_VERSION }}" | |
| message: "API version ${{ env.NEW_VERSION }}" | |
| - name: Create release | |
| uses: ncipollo/release-action@v1 | |
| with: | |
| tag: "${{ env.NEW_VERSION }}" | |
| prerelease: true | |
| artifacts: "${{ env.NEW_VERSION }}.tar.gz,${{ env.NEW_VERSION }}.zip" | |
| skipIfReleaseExists: true | |
| body: "API version ${{ env.NEW_VERSION }}" |