Skip to content

Commit

Permalink
updated actions
Browse files Browse the repository at this point in the history
  • Loading branch information
jankovicgd committed Dec 27, 2022
1 parent 55c053c commit 6e464f6
Show file tree
Hide file tree
Showing 4 changed files with 141 additions and 125 deletions.
111 changes: 9 additions & 102 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -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/[email protected]
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 .
121 changes: 121 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -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/[email protected]
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()
29 changes: 7 additions & 22 deletions .github/workflows/tests.yml → .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down
5 changes: 4 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
[build-system]
requires = ["setuptools"]
requires = ["setuptools", "wheel"]
build-backend = "setuptools.build_meta"

[tool.distutils.bdist_wheel]
universal = true

0 comments on commit 6e464f6

Please sign in to comment.