|
| 1 | +name: Release Helper |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + |
| 8 | +jobs: |
| 9 | + correct_repository: |
| 10 | + runs-on: ubuntu-latest |
| 11 | + steps: |
| 12 | + - name: fail on fork |
| 13 | + if: github.repository_owner != 'cmu-delphi' |
| 14 | + run: exit 1 |
| 15 | + |
| 16 | + create_release: |
| 17 | + needs: correct_repository |
| 18 | + runs-on: ubuntu-latest |
| 19 | + steps: |
| 20 | + - name: Check out code |
| 21 | + uses: actions/checkout@v2 |
| 22 | + with: |
| 23 | + ssh-key: ${{ secrets.CMU_DELPHI_DEPLOY_MACHINE_SSH }} |
| 24 | + - name: Set up Python 3.8 |
| 25 | + uses: actions/setup-python@v2 |
| 26 | + with: |
| 27 | + python-version: 3.8 |
| 28 | + - name: Extract version |
| 29 | + id: extract_version |
| 30 | + run: | |
| 31 | + python -m pip install bump2version |
| 32 | + echo -n "::set-output name=version::" |
| 33 | + bump2version --dry-run --list patch | grep ^current_version | sed -r s,"^.*=",, |
| 34 | + - name: Create Release |
| 35 | + id: create_release |
| 36 | + uses: release-drafter/release-drafter@v5 |
| 37 | + env: |
| 38 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 39 | + with: |
| 40 | + version: ${{ steps.extract_version.outputs.version }} |
| 41 | + publish: true |
| 42 | + outputs: |
| 43 | + version: ${{ steps.extract_version.outputs.version }} |
| 44 | + upload_url: ${{ steps.create_release.outputs.upload_url }} |
| 45 | + tag_name: ${{ steps.create_release.outputs.tag_name }} |
| 46 | + |
| 47 | + release_python_client: |
| 48 | + needs: create_release |
| 49 | + runs-on: ubuntu-latest |
| 50 | + steps: |
| 51 | + - name: Check out code |
| 52 | + uses: actions/checkout@v2 |
| 53 | + - name: Set up Python 3.8 |
| 54 | + uses: actions/setup-python@v2 |
| 55 | + with: |
| 56 | + python-version: 3.8 |
| 57 | + - name: Install build dependencies |
| 58 | + run: | |
| 59 | + python -m pip install --upgrade pip |
| 60 | + pip install wheel twine |
| 61 | + - name: Prepare package |
| 62 | + run: | |
| 63 | + cp src/client/*.py src/client/packaging/pypi/delphi_epidata/ |
| 64 | + - name: Create release |
| 65 | + working-directory: src/client/packaging/pypi |
| 66 | + run: | |
| 67 | + python setup.py sdist bdist_wheel |
| 68 | + - uses: actions/upload-artifact@v2 |
| 69 | + with: |
| 70 | + name: delphi_epidata_py |
| 71 | + path: src/client/packaging/pypi/dist/*.tar.gz |
| 72 | + - name: Upload Release Asset |
| 73 | + |
| 74 | + with: |
| 75 | + files: "src/client/packaging/pypi/dist/*.tar.gz" |
| 76 | + repo-token: ${{ secrets.GITHUB_TOKEN }} |
| 77 | + release-tag: ${{ needs.create_release.outputs.tag_name }} |
| 78 | + - name: Publish a Python distribution to PyPI |
| 79 | + uses: pypa/gh-action-pypi-publish@release/v1 |
| 80 | + with: |
| 81 | + user: __token__ |
| 82 | + password: ${{ secrets.DELPHI_PYPI_PROD_TOKEN }} |
| 83 | + packages_dir: src/client/packaging/pypi/dist/ |
| 84 | + skip_existing: true |
| 85 | + # repository_url: https://test.pypi.org/legacy/ |
| 86 | + |
| 87 | + release_js_client: |
| 88 | + needs: create_release |
| 89 | + runs-on: ubuntu-latest |
| 90 | + defaults: |
| 91 | + run: |
| 92 | + working-directory: src/client/packaging/npm |
| 93 | + steps: |
| 94 | + - name: Check out code |
| 95 | + uses: actions/checkout@v2 |
| 96 | + - uses: actions/setup-node@v2 |
| 97 | + with: |
| 98 | + node-version: '14.x' |
| 99 | + - name: Cache Node.js modules |
| 100 | + uses: actions/cache@v2 |
| 101 | + with: |
| 102 | + path: ~/.npm # npm cache files are stored in `~/.npm` on Linux/macOS |
| 103 | + key: ${{ runner.OS }}-node2-${{ hashFiles('**/package-lock.json') }} |
| 104 | + restore-keys: | |
| 105 | + ${{ runner.OS }}-node2- |
| 106 | + - run: npm ci |
| 107 | + - run: npm test |
| 108 | + - run: npm pack |
| 109 | + - name: Rename to a different name |
| 110 | + run: for f in *.tgz; do mv "$f" "$(echo "$f" | sed s/delphi_epidata-/delphi_epidata_js-/)"; done |
| 111 | + - uses: actions/upload-artifact@v2 |
| 112 | + with: |
| 113 | + name: delphi_epidata_js |
| 114 | + path: src/client/packaging/npm/*.tgz |
| 115 | + - name: Upload Release Asset |
| 116 | + |
| 117 | + with: |
| 118 | + files: "src/client/packaging/npm/*.tgz" |
| 119 | + repo-token: ${{ secrets.GITHUB_TOKEN }} |
| 120 | + release-tag: ${{ needs.create_release.outputs.tag_name }} |
| 121 | + - name: Publish to NPM |
| 122 | + uses: JS-DevTools/npm-publish@v1 |
| 123 | + with: |
| 124 | + token: ${{ secrets.DELPHI_NPM_TOKEN }} |
| 125 | + package: src/client/packaging/npm/package.json |
| 126 | + access: public |
| 127 | + check-version: true |
| 128 | + |
| 129 | + sync_dev: |
| 130 | + needs: correct_repository |
| 131 | + runs-on: ubuntu-latest |
| 132 | + steps: |
| 133 | + - name: Check out code |
| 134 | + uses: actions/checkout@v2 |
| 135 | + with: |
| 136 | + ref: dev |
| 137 | + ssh-key: ${{ secrets.CMU_DELPHI_DEPLOY_MACHINE_SSH }} |
| 138 | + - name: Reset dev branch |
| 139 | + run: | |
| 140 | + git fetch origin main:main |
| 141 | + git reset --hard main |
| 142 | + - name: Create pull request into dev |
| 143 | + uses: peter-evans/create-pull-request@v3 |
| 144 | + with: |
| 145 | + branch: bot/sync-main-dev |
| 146 | + commit-message: "chore: sync main-dev" |
| 147 | + base: dev |
| 148 | + title: "chore: sync main->dev" |
| 149 | + labels: chore |
| 150 | + reviewers: krivard |
| 151 | + assignees: krivard |
| 152 | + body: | |
| 153 | + Syncing Main->Dev. |
0 commit comments