diff --git a/.drone.yml b/.drone.yml index 6f376df..b234006 100644 --- a/.drone.yml +++ b/.drone.yml @@ -1,289 +1,230 @@ --- kind: pipeline -type: docker +type: vm name: testing +pool: + use: ubuntu + steps: -- name: build - image: golang:1.18 - commands: - - go test ./... - - sh scripts/build.sh + - name: build + image: golang:1.18 + commands: + - go test ./... + - sh scripts/build.sh --- kind: pipeline name: linux-amd64 +type: vm + +pool: + use: ubuntu platform: os: linux arch: amd64 steps: -- name: build-push - pull: always - image: golang:1.18 - commands: - - "go build -v -ldflags \"-X main.build=${DRONE_BUILD_NUMBER}\" -a -o release/linux/amd64/plugin" - environment: - CGO_ENABLED: 0 - GO111MODULE: on - when: - event: - exclude: - - tag - -- name: build-tag - pull: always - image: golang:1.18 - commands: - - "go build -v -ldflags \"-X main.version=${DRONE_TAG##v} -X main.build=${DRONE_BUILD_NUMBER}\" -a -o release/linux/amd64/plugin" - environment: - CGO_ENABLED: 0 - GO111MODULE: on - when: - event: - - tag - -- name: publish - pull: always - image: plugins/docker:linux-amd64 - settings: - auto_tag: true - auto_tag_suffix: linux-amd64 - dockerfile: docker/Dockerfile.linux.amd64 - password: - from_secret: docker_password - repo: plugins/artifactory - username: - from_secret: docker_username - when: - event: - exclude: - - pull_request - -- name: publish-ubi - pull: always - image: plugins/docker:linux-amd64 - settings: - auto_tag: true - auto_tag_suffix: linux-amd64-ubi - dockerfile: docker/Dockerfile.linux.ubi.amd64 - password: - from_secret: docker_password - repo: plugins/artifactory - username: - from_secret: docker_username - when: - event: - exclude: - - pull_request + - name: build-push + pull: always + image: golang:1.18 + commands: + - 'go build -v -ldflags "-X main.build=${DRONE_BUILD_NUMBER}" -a -o release/linux/amd64/plugin' + environment: + CGO_ENABLED: 0 + when: + event: + exclude: + - tag + + - name: build-tag + pull: always + image: golang:1.18 + commands: + - 'go build -v -ldflags "-X main.version=${DRONE_TAG##v} -X main.build=${DRONE_BUILD_NUMBER}" -a -o release/linux/amd64/plugin' + environment: + CGO_ENABLED: 0 + when: + event: + - tag + + - name: publish + pull: always + image: plugins/docker:linux-amd64 + settings: + auto_tag: true + auto_tag_suffix: linux-amd64 + dockerfile: docker/Dockerfile.linux.amd64 + password: + from_secret: docker_password + repo: plugins/artifactory + username: + from_secret: docker_username + when: + event: + exclude: + - pull_request trigger: ref: - - refs/heads/main - - "refs/tags/**" - - "refs/pull/**" + - refs/heads/main + - "refs/tags/**" + - "refs/pull/**" depends_on: -- testing + - testing --- kind: pipeline name: linux-arm64 +pool: + use: ubuntu_arm64 platform: os: linux arch: arm64 steps: -- name: build-push - pull: always - image: golang:1.18 - commands: - - "go build -v -ldflags \"-X main.build=${DRONE_BUILD_NUMBER}\" -a -o release/linux/arm64/plugin" - environment: - CGO_ENABLED: 0 - GO111MODULE: on - when: - event: - exclude: - - tag - -- name: build-tag - pull: always - image: golang:1.18 - commands: - - "go build -v -ldflags \"-X main.version=${DRONE_TAG##v} -X main.build=${DRONE_BUILD_NUMBER}\" -a -o release/linux/arm64/plugin" - environment: - CGO_ENABLED: 0 - GO111MODULE: on - when: - event: - - tag - -- name: publish - pull: always - image: plugins/docker:linux-arm64 - settings: - auto_tag: true - auto_tag_suffix: linux-arm64 - dockerfile: docker/Dockerfile.linux.arm64 - password: - from_secret: docker_password - repo: plugins/artifactory - username: - from_secret: docker_username - when: - event: - exclude: - - pull_request + - name: build-push + pull: always + image: golang:1.18 + commands: + - 'go build -v -ldflags "-X main.build=${DRONE_BUILD_NUMBER}" -a -o release/linux/arm64/plugin' + environment: + CGO_ENABLED: 0 + when: + event: + exclude: + - tag + + - name: build-tag + pull: always + image: golang:1.18 + commands: + - 'go build -v -ldflags "-X main.version=${DRONE_TAG##v} -X main.build=${DRONE_BUILD_NUMBER}" -a -o release/linux/arm64/plugin' + environment: + CGO_ENABLED: 0 + when: + event: + - tag + + - name: publish + pull: always + image: plugins/docker:linux-arm64 + settings: + auto_tag: true + auto_tag_suffix: linux-arm64 + dockerfile: docker/Dockerfile.linux.arm64 + password: + from_secret: docker_password + repo: plugins/artifactory + username: + from_secret: docker_username + when: + event: + exclude: + - pull_request trigger: ref: - - refs/heads/main - - "refs/tags/**" - - "refs/pull/**" + - refs/heads/main + - "refs/tags/**" + - "refs/pull/**" depends_on: -- testing + - testing --- kind: pipeline -type: ssh +type: vm name: windows-1809-amd64 -platform: - os: windows - -server: - host: windows.1809.amd64.plugins.drone.ci - password: - from_secret: windows_password - user: - from_secret: windows_username - -steps: -- name: build_latest - environment: - VERSION: 1809 - USERNAME: - from_secret: docker_username - PASSWORD: - from_secret: docker_password - commands: - - powershell.exe scripts/windows/latest.ps1 - when: - event: [ push ] - -- name: build_nano_latest - environment: - VERSION: 1809 - USERNAME: - from_secret: docker_username - PASSWORD: - from_secret: docker_password - commands: - - powershell.exe scripts/windows/latest_nano.ps1 - when: - event: [ push ] - -- name: build_tag - environment: - VERSION: 1809 - USERNAME: - from_secret: docker_username - PASSWORD: - from_secret: docker_password - commands: - - powershell.exe scripts/windows/tag.ps1 - when: - event: [ tag ] - -depends_on: - - testing - -trigger: - ref: - - refs/heads/main - - refs/tags/** - ---- -kind: pipeline -type: ssh -name: windows-1909-amd64 +pool: + use: windows platform: os: windows -server: - host: windows.1909.amd64.plugins.drone.ci - password: - from_secret: windows_password - user: - from_secret: windows_username - steps: -- name: build_latest - environment: - VERSION: 1909 - USERNAME: - from_secret: docker_username - PASSWORD: - from_secret: docker_password - commands: - - powershell.exe scripts/windows/latest.ps1 - when: - event: [ push ] - -- name: build_tag - environment: - VERSION: 1909 - USERNAME: - from_secret: docker_username - PASSWORD: - from_secret: docker_password - commands: - - powershell.exe scripts/windows/tag.ps1 - when: - event: [ tag ] + - name: build-push + pull: always + image: golang:1.18 + commands: + - 'go build -v -ldflags "-X main.build=${DRONE_BUILD_NUMBER}" -a -o release/windows/amd64/plugin' + environment: + CGO_ENABLED: 0 + when: + event: + exclude: + - tag + - name: build-tag + pull: always + image: golang:1.18 + commands: + - 'go build -v -ldflags "-X main.version=${DRONE_TAG##v} -X main.build=${DRONE_BUILD_NUMBER}" -a -o release/windows/amd64/plugin' + environment: + CGO_ENABLED: 0 + when: + event: + - tag + - name: publish + pull: always + image: plugins/docker:f0233d950ae87ee6cb5500b2d5497fe02aa338201c0bdce2619f443fd174cfa4 + settings: + auto_tag: true + auto_tag_suffix: windows-1809-amd64 + dockerfile: docker/Dockerfile.windows.amd64.1809 + password: + from_secret: docker_password + repo: plugins/artifactory + username: + from_secret: docker_username + when: + event: + exclude: + - pull_request depends_on: - testing trigger: ref: - - refs/heads/main - - refs/tags/** + - refs/heads/main + - refs/tags/** + - "refs/pull/**" --- kind: pipeline name: notifications +type: vm + +pool: + use: ubuntu platform: os: linux arch: amd64 steps: -- name: manifest - pull: always - image: plugins/manifest - settings: - ignore_missing: "true" - auto_tag: "true" - password: - from_secret: docker_password - spec: docker/manifest.tmpl - username: - from_secret: docker_username + - name: manifest + pull: always + image: plugins/manifest + settings: + ignore_missing: "true" + auto_tag: "true" + password: + from_secret: docker_password + spec: docker/manifest.tmpl + username: + from_secret: docker_username trigger: ref: - - refs/heads/main - - "refs/tags/**" + - refs/heads/main + - "refs/tags/**" depends_on: -- linux-amd64 -- linux-arm64 -- windows-1809-amd64 -- windows-1909-amd64 -... + - linux-amd64 + - linux-arm64 + - windows-1809-amd64 diff --git a/docker/Dockerfile.linux.arm b/docker/Dockerfile.linux.arm deleted file mode 100644 index 244a6bc..0000000 --- a/docker/Dockerfile.linux.arm +++ /dev/null @@ -1,19 +0,0 @@ -FROM arm32v6/alpine:3.12 as alpine -RUN apk add -U --no-cache ca-certificates - - -FROM arm32v6/alpine:3.12 - -ENV GODEBUG netdns=go -COPY --from=alpine /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ - -# Install jfrog cli with version 1.35.5 -RUN apk add --update \ - curl \ - && rm -rf /var/cache/apk/* -RUN curl -fL https://getcli.jfrog.io | sh /dev/stdin 1.35.5 -RUN mv ./jfrog /usr/local/bin/ -RUN chmod +x /usr/local/bin/jfrog - -ADD release/linux/arm/plugin /bin/ -ENTRYPOINT ["/bin/plugin"] \ No newline at end of file diff --git a/docker/Dockerfile.linux.ubi.amd64 b/docker/Dockerfile.linux.ubi.amd64 deleted file mode 100644 index b2fcd27..0000000 --- a/docker/Dockerfile.linux.ubi.amd64 +++ /dev/null @@ -1,14 +0,0 @@ -FROM registry.access.redhat.com/ubi8/ubi-minimal:8.6-751 -ENV GODEBUG netdns=go -ENV CI=true - -# Install jfrog cli with version 2.18.2 -RUN microdnf install curl ca-certificates \ - && rm -rf /var/cache/yum \ - && microdnf clean all -RUN curl -fL https://getcli.jfrog.io/v2-jf | sh /dev/stdin 2.18.2 -RUN mv ./jf /usr/local/bin/jfrog -RUN chmod +x /usr/local/bin/jfrog - -ADD release/linux/amd64/plugin /bin/ -ENTRYPOINT ["/bin/plugin"] diff --git a/docker/Dockerfile.windows.amd64.1803 b/docker/Dockerfile.windows.amd64.1803 deleted file mode 100644 index 08985c4..0000000 --- a/docker/Dockerfile.windows.amd64.1803 +++ /dev/null @@ -1,11 +0,0 @@ -# escape=` -FROM mcr.microsoft.com/windows/servercore:1803 -SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"] -USER ContainerAdministrator - -ENV GODEBUG=netdns=go -RUN mkdir /bin -RUN Invoke-WebRequest https://releases.jfrog.io/artifactory/jfrog-cli/v2/2.10.0/jfrog-cli-windows-amd64/jfrog.exe -OutFile C:/bin/jfrog.exe -ADD release/windows/amd64/plugin C:/bin/drone-artifactory.exe - -ENTRYPOINT [ "C:\\bin\\drone-artifactory.exe" ] \ No newline at end of file diff --git a/docker/Dockerfile.windows.amd64.1903 b/docker/Dockerfile.windows.amd64.1903 deleted file mode 100644 index ab68244..0000000 --- a/docker/Dockerfile.windows.amd64.1903 +++ /dev/null @@ -1,11 +0,0 @@ -# escape=` -FROM mcr.microsoft.com/windows/servercore:1903 -SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"] -USER ContainerAdministrator - -ENV GODEBUG=netdns=go -RUN mkdir /bin -RUN Invoke-WebRequest https://releases.jfrog.io/artifactory/jfrog-cli/v2/2.10.0/jfrog-cli-windows-amd64/jfrog.exe -OutFile C:/bin/jfrog.exe -ADD release/windows/amd64/plugin C:/bin/drone-artifactory.exe - -ENTRYPOINT [ "C:\\bin\\drone-artifactory.exe" ] \ No newline at end of file diff --git a/docker/Dockerfile.windows.amd64.1909 b/docker/Dockerfile.windows.amd64.1909 deleted file mode 100644 index 0ae848a..0000000 --- a/docker/Dockerfile.windows.amd64.1909 +++ /dev/null @@ -1,11 +0,0 @@ -# escape=` -FROM mcr.microsoft.com/windows/servercore:1909 -SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"] -USER ContainerAdministrator - -ENV GODEBUG=netdns=go -RUN mkdir /bin -RUN Invoke-WebRequest https://releases.jfrog.io/artifactory/jfrog-cli/v2/2.10.0/jfrog-cli-windows-amd64/jfrog.exe -OutFile C:/bin/jfrog.exe -ADD release/windows/amd64/plugin C:/bin/drone-artifactory.exe - -ENTRYPOINT [ "C:\\bin\\drone-artifactory.exe" ] \ No newline at end of file diff --git a/docker/Dockerfile.windows.nano.amd64.1809 b/docker/Dockerfile.windows.nano.amd64.1809 deleted file mode 100644 index e5ffec0..0000000 --- a/docker/Dockerfile.windows.nano.amd64.1809 +++ /dev/null @@ -1,21 +0,0 @@ -# escape=` - -FROM mcr.microsoft.com/windows/servercore:1809 as base -SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"] -USER ContainerAdministrator - -ENV GODEBUG=netdns=go -RUN mkdir /bin -RUN Invoke-WebRequest https://releases.jfrog.io/artifactory/jfrog-cli/v2/2.10.0/jfrog-cli-windows-amd64/jfrog.exe -OutFile C:/bin/jfrog.exe - -FROM mcr.microsoft.com/powershell:nanoserver-1809 -COPY --from=base /bin /bin - -ADD release/windows/amd64/plugin C:/bin/drone-artifactory.exe - -# https://github.com/PowerShell/PowerShell/issues/6211#issuecomment-367477137 -USER ContainerAdministrator -RUN setx /M PATH "%PATH%;C:\Program Files\PowerShell" - -SHELL ["pwsh", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"] -ENTRYPOINT [ "C:\\bin\\drone-artifactory.exe" ] \ No newline at end of file diff --git a/docker/manifest.tmpl b/docker/manifest.tmpl index 409df87..e43adc3 100644 --- a/docker/manifest.tmpl +++ b/docker/manifest.tmpl @@ -17,27 +17,9 @@ manifests: architecture: arm64 os: linux variant: v8 - - - image: plugins/artifactory:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}linux-arm - platform: - architecture: arm - os: linux - variant: v7 - image: plugins/artifactory:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}windows-1809-amd64 platform: architecture: amd64 os: windows - version: 1809 - - - image: plugins/artifactory:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}windows-1903-amd64 - platform: - architecture: amd64 - os: windows - version: 1903 - - - image: plugins/artifactory:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}windows-1909-amd64 - platform: - architecture: amd64 - os: windows - version: 1909 \ No newline at end of file + version: 1809 \ No newline at end of file diff --git a/scripts/windows/latest.ps1 b/scripts/windows/latest.ps1 deleted file mode 100644 index 98fe8b8..0000000 --- a/scripts/windows/latest.ps1 +++ /dev/null @@ -1,30 +0,0 @@ -# this script is used by the continuous integration server to -# build and publish the docker image for a commit to master. -$ErrorActionPreference = "Stop" - -$env:GOOS="windows" -$env:GOARCH="amd64" -$env:CGO_ENABLED="0" - -if (-not (Test-Path env:VERSION)) { - $env:VERSION="1809" -} - -echo $env:GOOS -echo $env:GOARCH -echo $env:VERSION - -# build the binary -Write-Host "+ go build -o release/windows/amd64/plugin.exe"; -go build -o release/windows/amd64/plugin - -# build and publish the docker image -docker login -u ${env:USERNAME} -p ${env:PASSWORD} -Write-Host "+ docker build -f docker/Dockerfile.windows.amd64.${env:VERSION} -t plugins/artifactory:windows-${env:VERSION}-amd64 ."; -docker build -f docker/Dockerfile.windows.amd64.${env:VERSION} -t plugins/artifactory:windows-${env:VERSION}-amd64 . -Write-Host "+ docker push plugins/artifactory:windows-${env:VERSION}-amd64" -docker push plugins/artifactory:windows-${env:VERSION}-amd64 - -# remove images from local cache -Write-Host "+ docker rmi plugins/artifactory:windows-${env:VERSION}-amd64" -docker rmi plugins/artifactory:windows-${env:VERSION}-amd64 diff --git a/scripts/windows/latest_nano.ps1 b/scripts/windows/latest_nano.ps1 deleted file mode 100644 index 5f2660e..0000000 --- a/scripts/windows/latest_nano.ps1 +++ /dev/null @@ -1,30 +0,0 @@ -# this script is used by the continuous integration server to -# build and publish the docker image for a commit to master. -$ErrorActionPreference = "Stop" - -$env:GOOS="windows" -$env:GOARCH="amd64" -$env:CGO_ENABLED="0" - -if (-not (Test-Path env:VERSION)) { - $env:VERSION="1809" -} - -echo $env:GOOS -echo $env:GOARCH -echo $env:VERSION - -# build the binary -Write-Host "+ go build -o release/windows/amd64/plugin.exe"; -go build -o release/windows/amd64/plugin - -# build and publish the docker image -docker login -u ${env:USERNAME} -p ${env:PASSWORD} -Write-Host "+ docker build -f docker/Dockerfile.windows.nano.amd64.${env:VERSION} -t plugins/artifactory:windows-${env:VERSION}-nano-amd64 ."; -docker build -f docker/Dockerfile.windows.nano.amd64.${env:VERSION} -t plugins/artifactory:windows-${env:VERSION}-nano-amd64 . -Write-Host "+ docker push plugins/artifactory:windows-${env:VERSION}-nano-amd64" -docker push plugins/artifactory:windows-${env:VERSION}-nano-amd64 - -# remove images from local cache -Write-Host "+ docker rmi plugins/artifactory:windows-${env:VERSION}-nano-amd64" -docker rmi plugins/artifactory:windows-${env:VERSION}-nano-amd64 diff --git a/scripts/windows/tag.ps1 b/scripts/windows/tag.ps1 deleted file mode 100644 index 52d0a79..0000000 --- a/scripts/windows/tag.ps1 +++ /dev/null @@ -1,62 +0,0 @@ -# this script is used by the continuous integration server to -# build and publish the docker image for a tagged revsision. -$ErrorActionPreference = "Stop" - -$env:GOOS="windows" -$env:GOARCH="amd64" -$env:CGO_ENABLED="0" - -if (-not (Test-Path env:VERSION)) { - $env:VERSION="1809" -} - -if (-not (Test-Path env:DRONE_SEMVER_SHORT)) { - echo "missing semver" - exit 1 -} - -# define the image tags -$env:IMAGE_PATCH="plugins/artifactory:${env:DRONE_SEMVER_SHORT}-windows-${env:VERSION}-amd64" -$env:IMAGE_MAJOR="plugins/artifactory:${env:DRONE_SEMVER_MAJOR}-windows-${env:VERSION}-amd64" -$env:IMAGE_MINOR="plugins/artifactory:${env:DRONE_SEMVER_MAJOR}.${env:DRONE_SEMVER_MINOR}-windows-${env:VERSION}-amd64" - -echo "build environment:" -echo $env:GOOS -echo $env:GOARCH -echo $env:VERSION - -# build the binary -Write-Host "+ go build -o release/windows/amd64/plugin" -go build -o release/windows/amd64/plugin - -# authenticate with the docker registry -docker login -u ${env:USERNAME} -p ${env:PASSWORD} - -echo "building images:" -echo ${env:IMAGE_PATCH} -echo ${env:IMAGE_MINOR} -echo ${env:IMAGE_MAJOR} - -# build and tag the docker images -Write-Host "+ docker build -f docker/Dockerfile.windows.amd64.${env:VERSION} -t ${env:IMAGE_PATCH} ." -docker build -f docker/Dockerfile.windows.amd64.${env:VERSION} -t ${env:IMAGE_PATCH} . -Write-Host "+ docker tag ${env:IMAGE_PATCH} ${env:IMAGE_MAJOR}" -docker tag ${env:IMAGE_PATCH} ${env:IMAGE_MAJOR} -Write-Host "+ docker tag ${env:IMAGE_PATCH} ${env:IMAGE_MINOR}" -docker tag ${env:IMAGE_PATCH} ${env:IMAGE_MINOR} - -# publish the docker images -Write-Host "+ docker push ${env:IMAGE_MAJOR}" -docker push ${env:IMAGE_MAJOR} -Write-Host "+ docker push ${env:IMAGE_MINOR}" -docker push ${env:IMAGE_MINOR} -Write-Host "+ docker push ${env:IMAGE_PATCH}" -docker push ${env:IMAGE_PATCH} - -# remove images after from local cache -Write-Host "+ docker rmi ${env:IMAGE_MAJOR}" -docker rmi ${env:IMAGE_MAJOR} -Write-Host "+ docker rmi ${env:IMAGE_MINOR}" -docker rmi ${env:IMAGE_MINOR} -Write-Host "+ docker rmi ${env:IMAGE_PATCH}" -docker rmi ${env:IMAGE_PATCH}