From 10cb72f955896e61432d415be76ac03aa50ee053 Mon Sep 17 00:00:00 2001 From: Robert Kaussow Date: Sat, 22 Feb 2020 17:39:28 +0100 Subject: [PATCH] cleanup --- .drone.jsonnet | 69 ++++++++++++++++++++++++++-------- .drone.yml | 52 ++++++++++++++++++------- Dockerfile.amd64 => Dockerfile | 3 +- manifest.tmpl | 5 ++- 4 files changed, 98 insertions(+), 31 deletions(-) rename Dockerfile.amd64 => Dockerfile (93%) diff --git a/.drone.jsonnet b/.drone.jsonnet index 404afe9..7a0d6bb 100644 --- a/.drone.jsonnet +++ b/.drone.jsonnet @@ -1,7 +1,6 @@ local PipelineBuild(arch='amd64') = { - local tag = 'linux-' + arch, kind: 'pipeline', - name: 'build-container-' + arch, + name: 'build-' + arch, platform: { os: 'linux', arch: arch, @@ -9,13 +8,14 @@ local PipelineBuild(arch='amd64') = { steps: [ { name: 'dryrun', - image: 'plugins/docker:' + tag, + image: 'plugins/docker', settings: { dry_run: true, - dockerfile: './Dockerfile.' + arch, - repo: 'xoxys/nginx', + dockerfile: 'Dockerfile', + repo: 'xoxys/${DRONE_REPO_NAME}', username: { from_secret: 'docker_username' }, password: { from_secret: 'docker_password' }, + build_args: [], }, when: { ref: [ @@ -25,14 +25,15 @@ local PipelineBuild(arch='amd64') = { }, { name: 'publish', - image: 'plugins/docker:' + tag, + image: 'plugins/docker', settings: { auto_tag: true, auto_tag_suffix: arch, - dockerfile: './Dockerfile.' + arch, - repo: 'xoxys/nginx', + dockerfile: 'Dockerfile', + repo: 'xoxys/${DRONE_REPO_NAME}', username: { from_secret: 'docker_username' }, password: { from_secret: 'docker_password' }, + build_args: [], }, when: { ref: [ @@ -41,6 +42,20 @@ local PipelineBuild(arch='amd64') = { ], }, }, + { + name: 'publish-gitea', + image: 'plugins/gitea-release', + settings: { + api_key: { from_secret: 'gitea_token' }, + base_url: 'https://gitea.rknet.org', + overwrite: true, + title: '${DRONE_TAG}', + note: 'CHANGELOG.md', + }, + when: { + ref: ['refs/tags/**'], + }, + }, ], }; @@ -57,9 +72,20 @@ local PipelineNotifications(depends_on=[]) = { name: 'manifest', settings: { ignore_missing: true, + tags: [ + '${DRONE_TAG}', + '${DRONE_TAG%-*}', + '${DRONE_TAG%.*}', + '${DRONE_TAG%%.*}', + ], username: { from_secret: 'docker_username' }, password: { from_secret: 'docker_password' }, - spec: './manifest.tmpl', + spec: 'manifest.tmpl', + }, + when: { + status: [ + 'success', + ], }, }, { @@ -69,23 +95,31 @@ local PipelineNotifications(depends_on=[]) = { DOCKERHUB_USERNAME: { from_secret: 'docker_username' }, DOCKERHUB_PASSWORD: { from_secret: 'docker_password' }, DOCKERHUB_REPO_PREFIX: 'xoxys', - DOCKERHUB_REPO_NAME: 'nginx', + DOCKERHUB_REPO_NAME: '${DRONE_REPO_NAME}', README_PATH: 'README.md', SHORT_DESCRIPTION: 'Rootless NGINX - High-performance HTTP server and reverse proxy', }, + when: { + status: [ + 'success', + ], + }, }, { - image: 'plugins/matrix', name: 'matrix', + image: 'plugins/matrix', settings: { - homeserver: 'https://matrix.rknet.org', - roomid: 'MtidqQXWWAtQcByBhH:rknet.org', + homeserver: { from_secret: 'matrix_homeserver' }, + roomid: { from_secret: 'matrix_roomid' }, template: 'Status: **{{ build.status }}**
Build: [{{ repo.Owner }}/{{ repo.Name }}]({{ build.link }}) ({{ build.branch }}) by {{ build.author }}
Message: {{ build.message }}', username: { from_secret: 'matrix_username' }, password: { from_secret: 'matrix_password' }, }, when: { - status: ['success', 'failure'], + status: [ + 'success', + 'failure', + ], }, }, ], @@ -94,7 +128,10 @@ local PipelineNotifications(depends_on=[]) = { 'refs/heads/master', 'refs/tags/**', ], - status: ['success', 'failure'], + status: [ + 'success', + 'failure', + ], }, depends_on: depends_on, }; @@ -102,6 +139,6 @@ local PipelineNotifications(depends_on=[]) = { [ PipelineBuild(arch='amd64'), PipelineNotifications(depends_on=[ - 'build-container-amd64', + 'build-amd64', ]), ] diff --git a/.drone.yml b/.drone.yml index f5a9da4..a2196b1 100644 --- a/.drone.yml +++ b/.drone.yml @@ -1,6 +1,6 @@ --- kind: pipeline -name: build-container-amd64 +name: build-amd64 platform: os: linux @@ -8,13 +8,13 @@ platform: steps: - name: dryrun - image: plugins/docker:linux-amd64 + image: plugins/docker settings: - dockerfile: ./Dockerfile.amd64 + dockerfile: Dockerfile dry_run: true password: from_secret: docker_password - repo: xoxys/nginx + repo: xoxys/${DRONE_REPO_NAME} username: from_secret: docker_username when: @@ -22,14 +22,14 @@ steps: - refs/pull/** - name: publish - image: plugins/docker:linux-amd64 + image: plugins/docker settings: auto_tag: true auto_tag_suffix: amd64 - dockerfile: ./Dockerfile.amd64 + dockerfile: Dockerfile password: from_secret: docker_password - repo: xoxys/nginx + repo: xoxys/${DRONE_REPO_NAME} username: from_secret: docker_username when: @@ -37,6 +37,19 @@ steps: - refs/heads/master - refs/tags/** +- name: publish-gitea + image: plugins/gitea-release + settings: + api_key: + from_secret: gitea_token + base_url: https://gitea.rknet.org + note: CHANGELOG.md + overwrite: true + title: ${DRONE_TAG} + when: + ref: + - refs/tags/** + --- kind: pipeline name: notifications @@ -52,29 +65,42 @@ steps: ignore_missing: true password: from_secret: docker_password - spec: ./manifest.tmpl + spec: manifest.tmpl + tags: + - ${DRONE_TAG} + - ${DRONE_TAG%-*} + - ${DRONE_TAG%.*} + - ${DRONE_TAG%%.*} username: from_secret: docker_username + when: + status: + - success - name: readme image: sheogorath/readme-to-dockerhub environment: DOCKERHUB_PASSWORD: from_secret: docker_password - DOCKERHUB_REPO_NAME: nginx + DOCKERHUB_REPO_NAME: ${DRONE_REPO_NAME} DOCKERHUB_REPO_PREFIX: xoxys DOCKERHUB_USERNAME: from_secret: docker_username README_PATH: README.md SHORT_DESCRIPTION: Rootless NGINX - High-performance HTTP server and reverse proxy + when: + status: + - success - name: matrix image: plugins/matrix settings: - homeserver: https://matrix.rknet.org + homeserver: + from_secret: matrix_homeserver password: from_secret: matrix_password - roomid: MtidqQXWWAtQcByBhH:rknet.org + roomid: + from_secret: matrix_roomid template: "Status: **{{ build.status }}**
Build: [{{ repo.Owner }}/{{ repo.Name }}]({{ build.link }}) ({{ build.branch }}) by {{ build.author }}
Message: {{ build.message }}" username: from_secret: matrix_username @@ -92,10 +118,10 @@ trigger: - failure depends_on: -- build-container-amd64 +- build-amd64 --- kind: signature -hmac: 4934bdb4da4822d1b66100616df27aa4c6b9b23fbec8191303def1ac2cce0764 +hmac: 58628427cc7d49043cf825e1419f8132b47ac392a79aac3a19056273dc517915 ... diff --git a/Dockerfile.amd64 b/Dockerfile similarity index 93% rename from Dockerfile.amd64 rename to Dockerfile index 597ea2b..72a554e 100644 --- a/Dockerfile.amd64 +++ b/Dockerfile @@ -1,7 +1,8 @@ FROM alpine:3.10 LABEL maintainer="Robert Kaussow " \ - org.label-schema.name="Nginx" \ + org.label-schema.name="nginx" \ + org.label-schema.vcs-url="https://gitea.rknet.org/docker/nginx" \ org.label-schema.vendor="Robert Kaussow" \ org.label-schema.schema-version="1.0" diff --git a/manifest.tmpl b/manifest.tmpl index faf2b86..ff0383e 100644 --- a/manifest.tmpl +++ b/manifest.tmpl @@ -2,7 +2,10 @@ image: xoxys/nginx:{{#if build.tag}}{{trimPrefix "v" build.tag}}{{else}}latest{{ {{#if build.tags}} tags: {{#each build.tags}} - - {{this}} + {{#if this}} + - {{trimPrefix "v" this}} + - {{trimPrefix "v" this}}-amd64 + {{/if}} {{/each}} {{/if}} manifests: