mirror of
https://github.com/transloadit/uppy.git
synced 2026-07-19 01:24:18 +00:00
* Fix yarn caching in github actions * improve cache take 2 from https://github.com/actions/cache/blob/main/examples.md#node---yarn-2 * fix yarn -> corepack yarn * fix order of corepack install * add --immutable to all
99 lines
4.7 KiB
YAML
99 lines
4.7 KiB
YAML
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' }}
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout sources
|
|
uses: actions/checkout@v2
|
|
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@v2
|
|
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@v2
|
|
with:
|
|
node-version: 16.x
|
|
- name: Install dependencies
|
|
run: corepack yarn install --immutable
|
|
- 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/robodog` to CDN if it was released
|
|
run: git diff --exit-code --quiet HEAD^ -- packages/@uppy/robodog/package.json || corepack yarn run uploadcdn @uppy/robodog
|
|
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: 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 }}
|