diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 33b6d7c21..0c118489f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,111 +1,18 @@ name: build on: push: - tags: - - "release-[0-9]+.[0-9]+.[0-9]+" - branches: [master] + paths: + - '.github/workflows/tests.yaml' + - 'setup.py' + - 'setup.cfg' + - 'MANIFEST.in' + - 'pyproject.toml' + - 'eoxserver/**' jobs: build-docker: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - - name: Branch name - id: branch_name + - name: Build the eoxserver docker image run: | - echo ::set-output name=SOURCE_BRANCH:: $([[ $GITHUB_REF == refs/heads/* ]] && echo ${GITHUB_REF#refs/heads/} || echo "") - echo ::set-output name=SOURCE_TAG::$([[ $GITHUB_REF == refs/tags/* ]] && echo ${GITHUB_REF#refs/tags/} || echo "") - - name: Login to Docker Hub - uses: docker/login-action@v1 - with: - username: ${{ secrets.DOCKER_USERNAME }} - password: ${{ secrets.DOCKER_PASSWORD }} - if: success() - - name: Tag docker latest image - run: | - docker tag eoxserver eoxa/eoxserver:latest - if: success() && steps.branch_name.outputs.SOURCE_BRANCH == 'master' - - name: Tag docker release image - run: | - docker tag eoxserver eoxa/eoxserver:${{ steps.branch_name.outputs.SOURCE_TAG }} - if: success() && steps.branch_name.outputs.SOURCE_TAG - - name: Push docker images - run: | - # TODO: --all-tags does not seem to work with the version on github-actions - # docker push --all-tags eoxa/eoxserver - for tag in $(docker image ls --format "{{.Tag}}" eoxa/eoxserver) ; do docker push "eoxa/eoxserver:$tag" ; done - if: success() - build-pypi: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - name: Branch name - id: branch_name - run: | - echo ::set-output name=SOURCE_BRANCH:: $([[ $GITHUB_REF == refs/heads/* ]] && echo ${GITHUB_REF#refs/heads/} || echo "") - echo ::set-output name=SOURCE_TAG::$([[ $GITHUB_REF == refs/tags/* ]] && echo ${GITHUB_REF#refs/tags/} || echo "") - - name: Build Python package - id: build_python_release - run: | - python -m pip install --upgrade pip - pip install setuptools wheel - python setup.py sdist bdist_wheel - echo ::set-output name=WHEEL_FILE::$(ls dist/*.whl) - echo ::set-output name=SRC_DIST_FILE::$(ls dist/*.tar.gz) - if: startsWith(steps.branch_name.outputs.SOURCE_TAG, 'release-') - - name: Push package to pypi - uses: pypa/gh-action-pypi-publish@master - with: - user: __token__ - password: ${{ secrets.PYPI_API_TOKEN }} - if: success() && startsWith(steps.branch_name.outputs.SOURCE_TAG, 'release-') - release: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - name: Branch name - id: branch_name - run: | - echo ::set-output name=SOURCE_BRANCH:: $([[ $GITHUB_REF == refs/heads/* ]] && echo ${GITHUB_REF#refs/heads/} || echo "") - echo ::set-output name=SOURCE_TAG::$([[ $GITHUB_REF == refs/tags/* ]] && echo ${GITHUB_REF#refs/tags/} || echo "") - - name: Create Release - id: create_release - uses: actions/create-release@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - tag_name: ${{ github.ref }} - release_name: ${{ steps.branch_name.outputs.SOURCE_TAG }} - draft: true - if: success() && startsWith(steps.branch_name.outputs.SOURCE_TAG, 'release-') - - name: Upload Release Asset Wheel - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_path: ${{ steps.build_python_release.outputs.WHEEL_FILE }} - asset_name: ${{ steps.build_python_release.outputs.WHEEL_FILE }} - asset_content_type: application/x-wheel+zip - if: success() && startsWith(steps.branch_name.outputs.SOURCE_TAG, 'release-') - - name: Upload Release Asset Source Dist - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps - asset_path: ${{ steps.build_python_release.outputs.SRC_DIST_FILE }} - asset_name: ${{ steps.build_python_release.outputs.SRC_DIST_FILE }} - asset_content_type: application/tar+gzip - if: success() && matrix.latest && startsWith(steps.branch_name.outputs.SOURCE_TAG, 'release-') - notify: - runs-on: ubuntu-20.04 - needs: release - steps: - - name: action-slack - uses: 8398a7/action-slack@v3.8.0 - with: - status: ${{ needs.run.result }} - fields: repo,message,commit,author,action,eventName,ref,workflow,job,took - env: - SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} - if: always() + docker build -t eoxserver . diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 000000000..5f0e12dc5 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,121 @@ +name: publish +on: + workflow_run: + workflows: + - test + tags: + - "release-[0-9]+.[0-9]+.[0-9]+" + branches: + - master + types: + - completed +jobs: + build-pypi: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Branch name + id: branch_name + run: | + echo ::set-output name=SOURCE_TAG::$([[ $GITHUB_REF == refs/tags/* ]] && echo ${GITHUB_REF#refs/tags/} || echo "") + - name: Build Python package + id: build_python_release + run: | + python -m pip install --upgrade pip + pip install setuptools wheel + python setup.py sdist bdist_wheel + echo ::set-output name=WHEEL_FILE::$(ls dist/*.whl) + echo ::set-output name=SRC_DIST_FILE::$(ls dist/*.tar.gz) + if: steps.branch_name.outputs.SOURCE_TAG + publish-docker: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Branch name + id: branch_name + run: | + echo ::set-output name=SOURCE_TAG::$([[ $GITHUB_REF == refs/tags/* ]] && echo ${GITHUB_REF#refs/tags/} || echo "") + - name: Login to Docker Hub + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + if: success() + - name: Tag docker latest image + run: | + docker tag eoxserver eoxa/eoxserver:latest + if: github.ref == 'refs/heads/master' + - name: Tag docker release image + run: | + docker tag eoxserver eoxa/eoxserver:${{ steps.branch_name.outputs.SOURCE_TAG }} + if: success() && steps.branch_name.outputs.SOURCE_TAG + - name: Push docker images + run: | + # TODO: --all-tags does not seem to work with the version on github-actions + # docker push --all-tags eoxa/eoxserver + for tag in $(docker image ls --format "{{.Tag}}" eoxa/eoxserver) ; do docker push "eoxa/eoxserver:$tag" ; done + if: success() + publish-pypi: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Branch name + id: branch_name + run: | + echo ::set-output name=SOURCE_TAG::$([[ $GITHUB_REF == refs/tags/* ]] && echo ${GITHUB_REF#refs/tags/} || echo "") + - name: Push package to pypi + uses: pypa/gh-action-pypi-publish@master + with: + user: __token__ + password: ${{ secrets.PYPI_API_TOKEN }} + if: success() && steps.branch_name.outputs.SOURCE_TAG + release: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Branch name + id: branch_name + run: | + echo ::set-output name=SOURCE_TAG::$([[ $GITHUB_REF == refs/tags/* ]] && echo ${GITHUB_REF#refs/tags/} || echo "") + - name: Create Release + id: create_release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ github.ref }} + release_name: ${{ steps.branch_name.outputs.SOURCE_TAG }} + draft: true + if: success() && steps.branch_name.outputs.SOURCE_TAG + - name: Upload Release Asset Wheel + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: ${{ steps.build_python_release.outputs.WHEEL_FILE }} + asset_name: ${{ steps.build_python_release.outputs.WHEEL_FILE }} + asset_content_type: application/x-wheel+zip + if: success() && steps.branch_name.outputs.SOURCE_TAG + - name: Upload Release Asset Source Dist + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps + asset_path: ${{ steps.build_python_release.outputs.SRC_DIST_FILE }} + asset_name: ${{ steps.build_python_release.outputs.SRC_DIST_FILE }} + asset_content_type: application/tar+gzip + if: success() && steps.branch_name.outputs.SOURCE_TAG + notify: + runs-on: ubuntu-20.04 + needs: release + steps: + - name: action-slack + uses: 8398a7/action-slack@v3.8.0 + with: + status: ${{ needs.run.result }} + fields: repo,message,commit,author,action,eventName,ref,workflow,job,took + env: + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} + if: always() diff --git a/.github/workflows/tests.yml b/.github/workflows/test.yml similarity index 82% rename from .github/workflows/tests.yml rename to .github/workflows/test.yml index 6918087f9..c64d1fb4a 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/test.yml @@ -1,22 +1,10 @@ -name: tests +name: test on: - push: - paths: - - '.github/workflows/tests.yaml' - - 'setup.py' - - 'setup.cfg' - - 'MANIFEST.in' - - 'pyproject.toml' - - 'eoxserver/**' - pull_request: - branches: [master] - paths: - - '.github/workflows/tests.yaml' - - 'setup.py' - - 'setup.cfg' - - 'MANIFEST.in' - - 'pyproject.toml' - - 'eoxserver/**' + workflow_run: + workflows: + - build + types: + - completed jobs: test: runs-on: ubuntu-latest @@ -29,10 +17,7 @@ jobs: - db: spatialite python_bin: python3 steps: - - uses: actions/checkout@v2 - - name: Build the eoxserver docker image - run: | - docker build -t eoxserver . + - uses: actions/checkout@v3 - name: Run the tests env: COMPOSE_INTERACTIVE_NO_CLI: 1 diff --git a/pyproject.toml b/pyproject.toml index fed528d4a..844669e16 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,3 +1,6 @@ [build-system] -requires = ["setuptools"] +requires = ["setuptools", "wheel"] build-backend = "setuptools.build_meta" + +[tool.distutils.bdist_wheel] +universal = true