diff --git a/.drone.yml b/.drone.yml deleted file mode 100644 index cc9c409..0000000 --- a/.drone.yml +++ /dev/null @@ -1,74 +0,0 @@ ---- -kind: pipeline -name: linux-amd64 - -platform: - os: linux - arch: amd64 - -trigger: - branch: - - main - event: - - push - -steps: - - name: publish - pull: always - image: plugins/docker:linux-amd64 - settings: - auto_tag: true - auto_tag_suffix: linux-amd64 - repo: gitea/test_env - password: - from_secret: docker_password - username: - from_secret: docker_username - ---- -kind: pipeline -name: linux-arm64 - -platform: - os: linux - arch: arm64 - -trigger: - branch: - - main - event: - - push - -steps: - - name: publish - pull: always - image: plugins/docker:linux-arm64 - settings: - auto_tag: true - auto_tag_suffix: linux-arm64 - repo: gitea/test_env - password: - from_secret: docker_password - username: - from_secret: docker_username - ---- -kind: pipeline -name: dry-run - -platform: - os: linux - arch: arm64 - -trigger: - event: - - pull_request - -steps: - - name: dryrun - pull: always - image: plugins/docker:linux-arm64 - settings: - dry_run: true - repo: gitea/test_env - tags: linux-arm64 diff --git a/.gitea/workflows/build-publish.yaml b/.gitea/workflows/build-publish.yaml new file mode 100644 index 0000000..289032a --- /dev/null +++ b/.gitea/workflows/build-publish.yaml @@ -0,0 +1,45 @@ +name: ci + +on: + push: + branches: [ main ] + +jobs: + docker: + strategy: + matrix: + arch: ['ubuntu-latest', 'arm-ubuntu-latest'] + go-version: ['1.19','1.20'] + git-version: ['2.38.4'] + golangci-lint-version: ['1.51.2'] + runs-on: ${{ matrix.arch }} + steps: + - uses: actions/checkout@v3 + - name: generate docker tag + run: | + if [ "${{ matrix.arch }}" == "ubuntu-latest" ]; then + echo ::set-output name=value::amd64 + else + echo ::set-output name=value::arm64 + fi + id: arch + - name: setup buildx + uses: https://github.com/docker/setup-buildx-action@v2 + - name: login into docker hub + run: | + BASE64_AUTH=`echo -n "$CI_REGISTRY_USER:$CI_REGISTRY_PASSWORD" | base64` + mkdir -p ~/.docker + echo "{\"auths\": {\"$CI_REGISTRY\": {\"auth\": \"$BASE64_AUTH\"}}}" > ~/.docker/config.json + env: + CI_REGISTRY: https://index.docker.io/v1/ + CI_REGISTRY_USER: ${{ secrets.DOCKER_USERNAME }} + CI_REGISTRY_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} + - name: build image + uses: https://github.com/docker/build-push-action@v4 + with: + push: true + tags: gitea/test_env:linux-${{ matrix.go-version }}-${{ steps.arch.outputs.value }} + build-args: | + GOLANG_VERSION=${{ matrix.go-version }} + GIT_VERSION=${{ matrix.git-version }} + GOLANGCI_LINT_VERSION=${{ matrix.golangci-lint-version }} diff --git a/.gitea/workflows/dry-run.yaml b/.gitea/workflows/dry-run.yaml new file mode 100644 index 0000000..970dde0 --- /dev/null +++ b/.gitea/workflows/dry-run.yaml @@ -0,0 +1,25 @@ +name: ci + +on: [pull_request] + +jobs: + docker: + strategy: + matrix: + go-version: ['1.19','1.20'] + git-version: ['2.38.4'] + golangci-lint-version: ['1.51.2'] + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: setup buildx + uses: https://github.com/docker/setup-buildx-action@v2 + - name: build image + uses: https://github.com/docker/build-push-action@v4 + with: + push: false + tags: gitea/test_env:linux-${{ matrix.go-version }}-amd64 + build-args: | + GOLANG_VERSION=${{ matrix.go-version }} + GIT_VERSION=${{ matrix.git-version }} + GOLANGCI_LINT_VERSION=${{ matrix.golangci-lint-version }} diff --git a/Dockerfile b/Dockerfile index 2a11b77..0f067f0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,15 @@ -FROM golang:1.20-bullseye +ARG GOLANG_VERSION=1.20 +FROM golang:${GOLANG_VERSION}-bullseye + +ARG GIT_VERSION=2.38.4 +ARG GOLANGCI_LINT_VERSION=1.51.0 + ARG GITEA_ID=1000 ARG GITEA_GID=1000 +ENV GIT_VERSION=${GIT_VERSION} +ENV GOLANGCI_LINT_VERSION=${GOLANGCI_LINT_VERSION} + RUN addgroup \ --gid $GITEA_GID \ gitea && \ @@ -12,17 +20,17 @@ RUN addgroup \ --gid $GITEA_GID \ gitea -# version-lock git to v2.38.4 to match alpine 3.17 -RUN curl -SL https://github.com/git/git/archive/v2.38.4.tar.gz \ - | tar -xzv -C /go \ +# version-lock git to v${GIT_VERSION} to match alpine 3.17 +RUN curl -SL https://github.com/git/git/archive/v${GIT_VERSION}.tar.gz \ + | tar -xz -C /go \ && apt-get update \ && apt-get install -y libcurl4-gnutls-dev libexpat1-dev gettext libz-dev libssl-dev \ - && make -C /go/git-2.38.4 prefix=/usr all \ - && make -C /go/git-2.38.4 prefix=/usr install \ - && rm -rf /go/git-2.38.4 \ + && make -C /go/git-${GIT_VERSION} prefix=/usr all \ + && make -C /go/git-${GIT_VERSION} prefix=/usr install \ + && rm -rf /go/git-${GIT_VERSION} \ # install git-lfs && curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | bash \ && apt-get install -y git-lfs \ # install golangci-lint - && go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.51.0 \ + && go install github.com/golangci/golangci-lint/cmd/golangci-lint@v${GOLANGCI_LINT_VERSION} \ && golangci-lint --version diff --git a/README.md b/README.md index 8e3c22b..67dad16 100644 --- a/README.md +++ b/README.md @@ -2,10 +2,10 @@ A docker image for Gitea ci test -- From golang:1.19 -- upgrade git to v2.39.1 +- From golang:1.20 +- upgrade git to v2.38.4 - install git-lfs -- install [golangci-lint](https://github.com/golangci/golangci-lint) v1.51.1 +- install [golangci-lint](https://github.com/golangci/golangci-lint) v1.51.2 # development environment build