From 01464f83f179f4a8b4b3bd243a8ee6fe7f547bc4 Mon Sep 17 00:00:00 2001 From: Max Anderson Date: Sun, 13 Dec 2020 13:34:25 -0800 Subject: [PATCH] Semantic release (#47) * Switch to semantic-release * Add semantic-release configuration --- .github/.releaserc.json | 8 ++++ .github/workflows/publish.yaml | 40 +++++++++++++++++++ .github/workflows/pythonpublish.yml | 59 ----------------------------- .github/workflows/release.yaml | 28 ++++++++++++++ 4 files changed, 76 insertions(+), 59 deletions(-) create mode 100644 .github/.releaserc.json create mode 100644 .github/workflows/publish.yaml delete mode 100644 .github/workflows/pythonpublish.yml create mode 100644 .github/workflows/release.yaml diff --git a/.github/.releaserc.json b/.github/.releaserc.json new file mode 100644 index 0000000..f6bb235 --- /dev/null +++ b/.github/.releaserc.json @@ -0,0 +1,8 @@ +{ + "plugins": [ + ["@semantic-release/commit-analyzer"], + ["@semantic-release/release-notes-generator"], + ["@semantic-release/github"] + ], + "preset": "eslint" +} diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml new file mode 100644 index 0000000..4e423bf --- /dev/null +++ b/.github/workflows/publish.yaml @@ -0,0 +1,40 @@ +name: Publish release to PyPI + +on: + release: + types: + - published + +jobs: + deploy: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v1 + - name: Set up Python 3.7 + uses: actions/setup-python@v1 + with: + python-version: 3.7 + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install setuptools wheel twine pyaml + - name: Trigger docs update + run: | + curl -X POST https://api.github.com/repos/reflexivesecurity/reflex-docs-infrastructure/dispatches \ + -H "Accept: application/vnd.github.everest-preview+json" \ + -H "Authorization: token $GITHUB_TOKEN" \ + --data '{"event_type": "deploy"}' + env: + GITHUB_TOKEN: ${{ secrets.CLOUDMITIGATOR_GITHUB_PAT }} + - name: Set version + run: | + echo "VERSION=$(gh release view | sed -n 2p | awk '{ print $2 }')" >> $GITHUB_ENV + echo "EGG=$(ls dist)" >> $GITHUB_ENV + - name: Build and publish + env: + TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} + TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} + run: | + export VERSION=${{ env.VERSION }} + python setup.py sdist bdist_wheel + twine upload dist/* diff --git a/.github/workflows/pythonpublish.yml b/.github/workflows/pythonpublish.yml deleted file mode 100644 index ecc3995..0000000 --- a/.github/workflows/pythonpublish.yml +++ /dev/null @@ -1,59 +0,0 @@ -name: Upload Python Package - -on: - push: - branches: - - master - -jobs: - deploy: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v1 - - name: Set up Python 3.7 - uses: actions/setup-python@v1 - with: - python-version: 3.7 - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install setuptools wheel twine pyaml cloudmitigator-semantic - - name: See if Version Changed - run: | - CHANGED=$(semantic changed) - if [ "${CHANGED}" == "True" ] - then - echo ::set-env name=VERSION_CHANGED::${CHANGED} - echo ::set-env name=VERSION::$(semantic version) - echo ::set-env name=EGG::$(ls dist) - echo ::set-env name=RELEASE_BODY::$(semantic release-body) - fi - - name: Create Release - if: env.VERSION_CHANGED - id: create_release - uses: actions/create-release@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token - with: - tag_name: ${{ env.VERSION }} - release_name: Release ${{ env.VERSION }} - body: ${{ env.RELEASE_BODY }} - draft: false - prerelease: false - - name: Trigger deploy - run: | - curl -X POST https://api.github.com/repos/reflexivesecurity/reflex-docs-infrastructure/dispatches \ - -H "Accept: application/vnd.github.everest-preview+json" \ - -H "Authorization: token $GITHUB_TOKEN" \ - --data '{"event_type": "deploy"}' - env: - GITHUB_TOKEN: ${{ secrets.CLOUDMITIGATOR_GITHUB_PAT }} - - name: Build and publish - if: env.VERSION_CHANGED - env: - TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} - TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} - run: | - export VERSION=${{ env.VERSION }} - python setup.py sdist bdist_wheel - twine upload dist/* diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 0000000..a5bc8d4 --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,28 @@ +name: Create new release + +on: + push: + branches: + - master + +jobs: + release: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Set up node + uses: actions/setup-node@v1 + with: + node-version: '12.x' + - name: Install dependencies + run: | + npm install @semantic-release/commit-analyzer \ + @semantic-release/release-notes-generator \ + @semantic-release/github \ + conventional-changelog-eslint \ + semantic-release + - name: Create release + run: | + npx semantic-release -e ./.github/.releaserc.json + env: + GITHUB_TOKEN: ${{ secrets.CLOUDMITIGATOR_GITHUB_PAT }}