123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160 |
- name: Release
- on:
- pull_request_review:
- types: [submitted]
- jobs:
- release:
- name: Publish releases
- if: ${{ github.event.review.state == 'approved' && github.event.sender.login == github.event.pull_request.assignee.login && github.event.pull_request.head.ref == 'release-candidate' }}
- outputs:
- companionWasReleased: ${{ steps.checkIfCompanionWasReleased.outputs.version }}
- runs-on: ubuntu-latest
- steps:
- - name: Checkout sources
- uses: actions/checkout@v3
- with:
- fetch-depth: 2
- - name: Get yarn cache directory path
- id: yarn-cache-dir-path
- run: echo "::set-output name=dir::$(corepack yarn config get cacheFolder)"
- - uses: actions/cache@v3
- id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
- with:
- path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
- key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
- restore-keys: |
- ${{ runner.os }}-yarn-
- - name: Install Node.js
- uses: actions/setup-node@v3
- with:
- node-version: lts/*
- - name: Install dependencies
- run: corepack yarn install --immutable
- env:
- # https://docs.cypress.io/guides/references/advanced-installation#Skipping-installation
- CYPRESS_INSTALL_BINARY: 0
- - name: Get CHANGELOG diff
- run: git --no-pager diff HEAD^ -- CHANGELOG.md | awk '{ if( substr($0,0,1) == "+" && $1 != "+##" && $1 != "+Released:" && $1 != "+++" ) { print substr($0,2) } }' > CHANGELOG.diff.md
- - name: Copy README for `uppy` package
- run: cp README.md packages/uppy/.
- - name: Build before publishing
- run: corepack yarn run build
- - name: Hack to allow the publish of the Angular package
- run: corepack yarn workspace @uppy/angular prepublishOnly
- - name: Login to NPM
- run: corepack yarn config set npmAuthToken ${{ toJSON(secrets.NPM_TOKEN) }}
- - name: Publish to NPM
- run: corepack yarn workspaces foreach --no-private npm publish --access public --tolerate-republish
- - name: Merge PR
- id: merge
- run: |
- gh api -X PUT repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/merge \
- -F merge_method="squash" \
- -F commit_message="$(cat CHANGELOG.diff.md)" \
- --jq 'if .merged then "##[set-output name=sha;]"+.sha else error("not merged") end'
- env:
- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- - name: Create tags
- run: |
- git --no-pager diff --name-only HEAD^ | awk '$0 ~ /^packages\/.+\/package\.json$/ { print "jq -r '"'"'\"gh api /repos/{owner}/{repo}/git/refs -f ref=\\\"refs/tags/\"+.name+\"@\"+.version+\"\\\" -f sha=${{ steps.merge.outputs.sha }}\"'"'"' < " $0 }' > createTags.sh
- cat createTags.sh
- sh createTags.sh | sh
- env:
- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- - name: Get Uppy version number
- id: uppyVersion
- run: jq -r '"##[set-output name=version;]"+.version' < packages/uppy/package.json
- - name: Create GitHub release
- run: gh release create uppy@${{ steps.uppyVersion.outputs.version }} -t "Uppy ${{ steps.uppyVersion.outputs.version }}" -F CHANGELOG.diff.md
- env:
- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- - name: Upload `uppy` to CDN
- run: corepack yarn run uploadcdn uppy
- env:
- EDGLY_KEY: ${{secrets.EDGLY_KEY}}
- EDGLY_SECRET: ${{secrets.EDGLY_SECRET}}
- - name: Upload `@uppy/locales` to CDN if it was released
- run: git diff --exit-code --quiet HEAD^ -- packages/@uppy/locales/package.json ||corepack yarn run uploadcdn @uppy/locales
- env:
- EDGLY_KEY: ${{secrets.EDGLY_KEY}}
- EDGLY_SECRET: ${{secrets.EDGLY_SECRET}}
- - name: Check if Companion was released
- id: checkIfCompanionWasReleased
- run: git diff --exit-code --quiet HEAD^ -- packages/@uppy/companion/package.json || echo "::set-output name=version::$(jq .version < packages/@uppy/companion/package.json)"
- - name: Remove release-candidate branch
- run: gh api -X DELETE repos/${{ github.repository }}/git/refs/heads/release-candidate || echo "Already deleted"
- env:
- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- - name: Remove release branch
- run: gh api -X DELETE repos/${{ github.repository }}/git/refs/heads/release
- env:
- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- - name: Disable Release workflow
- run: gh workflow disable Release --repo ${{ github.repository }}
- env:
- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- - name: In case of failure
- if: ${{ failure() }}
- run: gh pr comment ${{ github.event.pull_request.number }} --body "Release job failed, please take action."
- env:
- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- # See also companion-deploy.yml
- docker:
- name: DockerHub
- needs: release
- if: ${{ needs.release.outputs.companionWasReleased }}
- runs-on: ubuntu-latest
- env:
- DOCKER_BUILDKIT: 0
- COMPOSE_DOCKER_CLI_BUILD: 0
- steps:
- - name: Checkout sources
- uses: actions/checkout@v3
- - name: Docker meta
- id: docker_meta
- uses: docker/metadata-action@v4
- with:
- images: transloadit/companion
- tags: |
- type=edge
- type=semver,pattern={{version}},value=${{ needs.release.outputs.companionWasReleased }}
- # set latest tag for default branch
- type=raw,value=latest,enable=true
- - uses: docker/setup-qemu-action@v2
- - uses: docker/setup-buildx-action@v2
- - name: Log in to DockerHub
- uses: docker/login-action@v2
- with:
- username: ${{secrets.DOCKER_USERNAME}}
- password: ${{secrets.DOCKER_PASSWORD}}
- - name: Build and push
- uses: docker/build-push-action@v3
- with:
- push: true
- context: .
- platforms: linux/amd64,linux/arm64
- file: Dockerfile
- tags: ${{ steps.docker_meta.outputs.tags }}
- labels: ${{ steps.docker_meta.outputs.labels }}
- heroku:
- name: Heroku
- needs: release
- if: ${{ needs.release.outputs.companionWasReleased }}
- runs-on: ubuntu-latest
- steps:
- - name: Checkout sources
- uses: actions/checkout@v3
- - name: Alter dockerfile
- run: |
- sed -i 's/^EXPOSE 3020$/EXPOSE $PORT/g' Dockerfile
- - name: Deploy to heroku
- uses: akhileshns/heroku-deploy@v3.12.12
- with:
- heroku_api_key: ${{secrets.HEROKU_API_KEY}}
- heroku_app_name: companion-demo
- heroku_email: ${{secrets.HEROKU_EMAIL}}
- usedocker: true
|