From b7b3abc4621f40474145e889b71d5f0cf3788e46 Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Thu, 2 Jan 2020 13:49:24 +0100 Subject: [PATCH] actions: automatically create release when version/* tag is created, run tests before creating release --- .github/workflows/ci.yml | 12 ++++---- .github/workflows/release.yml | 20 ++----------- .github/workflows/tag.yml | 53 +++++++++++++++++++++++++++++++++++ 3 files changed, 62 insertions(+), 23 deletions(-) create mode 100644 .github/workflows/tag.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 625cf94c2..6e58d7ac8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -9,7 +9,7 @@ env: jobs: # Linting pylint: - runs-on: [ubuntu-latest] + runs-on: ubuntu-latest steps: - uses: actions/checkout@v1 - uses: actions/setup-python@v1 @@ -26,7 +26,7 @@ jobs: - name: Lint with pylint run: pipenv run pylint passbook black: - runs-on: [ubuntu-latest] + runs-on: ubuntu-latest steps: - uses: actions/checkout@v1 - uses: actions/setup-python@v1 @@ -43,7 +43,7 @@ jobs: - name: Lint with black run: pipenv run black --check passbook prospector: - runs-on: [ubuntu-latest] + runs-on: ubuntu-latest steps: - uses: actions/checkout@v1 - uses: actions/setup-python@v1 @@ -60,7 +60,7 @@ jobs: - name: Lint with prospector run: pipenv run prospector bandit: - runs-on: [ubuntu-latest] + runs-on: ubuntu-latest steps: - uses: actions/checkout@v1 - uses: actions/setup-python@v1 @@ -95,7 +95,7 @@ jobs: image: redis:latest ports: - 6379:6379 - runs-on: [ubuntu-latest] + runs-on: ubuntu-latest steps: - uses: actions/checkout@v1 - uses: actions/setup-python@v1 @@ -129,7 +129,7 @@ jobs: image: redis:latest ports: - 6379:6379 - runs-on: [ubuntu-latest] + runs-on: ubuntu-latest steps: - uses: actions/checkout@v1 - uses: actions/setup-python@v1 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index aa3aae4cc..93c5e23b4 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -7,7 +7,7 @@ on: jobs: # Build build-server: - runs-on: [ubuntu-latest] + runs-on: ubuntu-latest steps: - uses: actions/checkout@v1 - name: Docker Login Registry @@ -26,7 +26,7 @@ jobs: - name: Push Docker Container to Registry (latest) run: docker push beryju/passbook:latest build-static: - runs-on: [ubuntu-latest] + runs-on: ubuntu-latest services: postgres: image: postgres:latest @@ -58,7 +58,7 @@ jobs: needs: - build-server - build-static - runs-on: [ubuntu-latest] + runs-on: ubuntu-latest steps: - uses: actions/checkout@v1 - name: Run test suite in final docker images @@ -68,17 +68,3 @@ jobs: docker-compose up --no-start docker-compose start postgresql redis docker-compose run -u root server bash -c "pip install --no-cache -r requirements-dev.txt && ./manage.py test" - package-helm: - needs: - - test-release - runs-on: [ubuntu-latest] - steps: - - uses: actions/checkout@v1 - - name: Install Helm - run: | - apt update && apt install -y curl - curl https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3 | bash - - name: Helm package - run: | - helm dependency update helm/ - helm package helm/ diff --git a/.github/workflows/tag.yml b/.github/workflows/tag.yml new file mode 100644 index 000000000..1c2177b30 --- /dev/null +++ b/.github/workflows/tag.yml @@ -0,0 +1,53 @@ +on: + push: + tags: + - 'version/*' + +name: Create Release from Tag + +jobs: + build: + name: Create Release from Tag + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@master + - name: Pre-release test + run: | + export PASSBOOK_DOMAIN=localhost + docker-compose pull + docker build + --no-cache + -t beryju/passbook:latest + -f Dockerfile . + docker-compose up --no-start + docker-compose start postgresql redis + docker-compose run -u root server bash -c "pip install --no-cache -r requirements-dev.txt && ./manage.py test" + - name: Install Helm + run: | + apt update && apt install -y curl + curl https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3 | bash + - name: Helm package + run: | + helm dependency update helm/ + helm package helm/ + mv passbook-*.tgz passbook-chart.tgz + - name: Create Release + id: create_release + uses: actions/create-release@v1.0.0 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ github.ref }} + release_name: Release ${{ github.ref }} + draft: false + prerelease: false + - name: Create Release from Tag + id: upload-release-asset + uses: actions/upload-release-asset@v1.0.1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: ./passbook-chart.tgz + asset_name: passbook-chart.tgz + asset_content_type: application/gzip