From ed7efa5c8e23157d377f3f2de8a15e9548aea1bc Mon Sep 17 00:00:00 2001 From: Dave Henderson Date: Tue, 17 Dec 2024 11:58:59 -0500 Subject: [PATCH] ci(fix): Attempt to fix release.yml Signed-off-by: Dave Henderson --- .github/workflows/docker-release.yml | 76 ----------------- .github/workflows/release-please.yml | 18 ---- .github/workflows/release.yml | 122 ++++++++++++++++++++++----- packaging/alpine/APKBUILD.tmpl | 38 +++++++++ 4 files changed, 138 insertions(+), 116 deletions(-) delete mode 100644 .github/workflows/docker-release.yml create mode 100644 packaging/alpine/APKBUILD.tmpl diff --git a/.github/workflows/docker-release.yml b/.github/workflows/docker-release.yml deleted file mode 100644 index a807d474d..000000000 --- a/.github/workflows/docker-release.yml +++ /dev/null @@ -1,76 +0,0 @@ -name: Docker Release Build - -on: - release: - types: [published] - -jobs: - docker-release-build: - runs-on: ubuntu-latest - env: - TAG_NAME: ${{ github.event.release.tag_name }} - steps: - - name: Set up QEMU - uses: docker/setup-qemu-action@v3.2.0 - - name: Set up Docker Buildx - id: buildx - uses: docker/setup-buildx-action@v3.8.0 - with: - version: v0.14.1 - driver-opts: | - image=moby/buildkit:buildx-stable-1 - network=host - - name: Available platforms - run: echo {{ `${{ steps.buildx.outputs.platforms }}` }} - - run: docker info && docker version - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - name: Login to GHCR - uses: docker/login-action@v3.3.0 - with: - registry: ghcr.io - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - name: Login to DockerHub - uses: docker/login-action@v3.3.0 - with: - # NOTE: DOCKERHUB_TOKEN and DOCKERHUB_USERNAME must be present in https://github.com/hairyhenderson/gomplate/settings - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - - name: Build & Push - run: | - export srcrepo=${{ github.repository}} - - make docker-multi COMMIT=${{ github.sha }} DOCKER_REPO=${srcrepo} BUILDX_ACTION=--push - - set -x - export repo=${srcrepo} - export git_tag=${TAG_NAME} - export major_version=${git_tag%\.*} - docker buildx imagetools create -t ${repo}:stable ${srcrepo}:latest - docker buildx imagetools create -t ${repo}:${git_tag} ${srcrepo}:latest - docker buildx imagetools create -t ${repo}:${major_version} ${srcrepo}:latest - - docker buildx imagetools create -t ${repo}:stable-alpine ${srcrepo}:alpine - docker buildx imagetools create -t ${repo}:${git_tag}-alpine ${srcrepo}:alpine - docker buildx imagetools create -t ${repo}:${major_version}-alpine ${srcrepo}:alpine - - export repo=gomplate/gomplate - docker buildx imagetools create -t ${repo}:stable ${srcrepo}:latest - docker buildx imagetools create -t ${repo}:${git_tag} ${srcrepo}:latest - docker buildx imagetools create -t ${repo}:${major_version} ${srcrepo}:latest - - docker buildx imagetools create -t ${repo}:stable-alpine ${srcrepo}:alpine - docker buildx imagetools create -t ${repo}:${git_tag}-alpine ${srcrepo}:alpine - docker buildx imagetools create -t ${repo}:${major_version}-alpine ${srcrepo}:alpine - - # and now GHCR - export repo=ghcr.io/${srcrepo} - docker buildx imagetools create -t ${repo}:stable ${srcrepo}:latest - docker buildx imagetools create -t ${repo}:${git_tag} ${srcrepo}:latest - docker buildx imagetools create -t ${repo}:${major_version} ${srcrepo}:latest - - docker buildx imagetools create -t ${repo}:stable-alpine ${srcrepo}:alpine - docker buildx imagetools create -t ${repo}:${git_tag}-alpine ${srcrepo}:alpine - docker buildx imagetools create -t ${repo}:${major_version}-alpine ${srcrepo}:alpine diff --git a/.github/workflows/release-please.yml b/.github/workflows/release-please.yml index 233e48572..97569b978 100644 --- a/.github/workflows/release-please.yml +++ b/.github/workflows/release-please.yml @@ -221,21 +221,3 @@ jobs: --repo ${{ github.repository }} env: GH_TOKEN: ${{ steps.app-token.outputs.token }} - deploy-homebrew: - runs-on: ubuntu-latest - needs: create-release - steps: - - uses: actions/create-github-app-token@v1 - id: app-token - with: - app-id: ${{ vars.APP_ID }} - private-key: ${{ secrets.PRIVATE_KEY }} - - name: Set up Homebrew - id: set-up-homebrew - uses: Homebrew/actions/setup-homebrew@master - - name: Bump packages - uses: Homebrew/actions/bump-packages@master - with: - token: ${{ steps.app-token.outputs.token }} - formulae: gomplate - fork: false diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 5dd5e6aa8..310d7708d 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -3,6 +3,10 @@ name: Deploy Released Assets on: release: types: [published] + push: + branches: + - release-fix-attempt + workflow_dispatch: permissions: contents: write @@ -14,7 +18,8 @@ jobs: environment: name: aports env: - TAG_NAME: ${{ github.event.release.tag_name }} + # TAG_NAME: ${{ github.event.release.tag_name }} + TAG_NAME: v4.3.0 steps: - uses: actions/create-github-app-token@v1 id: app-token @@ -33,31 +38,37 @@ jobs: # need gomplate to template the APKBUILD! gh release download ${TAG_NAME} --skip-existing -p gomplate_linux-amd64 + chmod 755 gomplate_linux-amd64 env: GH_TOKEN: ${{ steps.app-token.outputs.token }} - name: checkout alpinelinux/aports run: | - git config user.name "${{ github.actor }}" - git config user.email "${{ github.actor_id }}+${{ github.actor }}@users.noreply.github.com" - git clone https://gitlab.alpinelinux.org/hairyhenderson/aports.git - git remote add upstream https://gitlab.alpinelinux.org/alpine/aports.git + set -ex + git config --global user.name "${{ github.actor }}" + git config --global user.email "${{ github.actor_id }}+${{ github.actor }}@users.noreply.github.com" + git clone -v https://gitlab.alpinelinux.org/hairyhenderson/aports.git cd aports + # note: this token expires, so needs to be rotated periodically + git remote set-url origin "https://oauth2:${{ secrets.GITLAB_ACCESS_TOKEN }}@gitlab.alpinelinux.org/hairyhenderson/aports.git" + git remote add upstream https://gitlab.alpinelinux.org/alpine/aports.git git checkout master - name: update fork run: | + set -ex cd aports - git fetch upstream + git fetch -v upstream git rebase upstream/master git push - name: upgrade gomplate in aports run: | + set -ex + export VERSION=${TAG_NAME#v} + cd aports/community/gomplate git checkout -b upgrade-gomplate-aport-${VERSION} - export VERSION=${TAG_NAME#v} - export ENVJSON="{\"version\": \"${VERSION}\", \"sha512\": \"${{ steps.artifacts.outputs.sha512sum }}\" }" - gomplate_linux-amd64 -c .=env:///ENVJSON\?type=application/json \ + ../../../gomplate_linux-amd64 -c .=env:///ENVJSON\?type=application/json \ -f ../../../packaging/alpine/APKBUILD.tmpl \ -o APKBUILD @@ -70,27 +81,19 @@ jobs: -m "community/gomplate: upgrade to ${VERSION}" \ -m "https://github.com/${{ github.repository }}/releases/tag/${TAG_NAME}" deploy-homebrew: - runs-on: ubuntu-latest + # run on macOS - this doesn't work in Linuxbrew + runs-on: macos-latest environment: name: homebrew env: - TAG_NAME: ${{ github.event.release.tag_name }} + # TAG_NAME: ${{ github.event.release.tag_name }} + TAG_NAME: v4.3.0 steps: - uses: actions/create-github-app-token@v1 id: app-token with: app-id: ${{ vars.APP_ID }} private-key: ${{ secrets.PRIVATE_KEY }} - # - name: Retrieve release artifacts - # id: artifacts - # run: | - # # need the checksum and archive - # gh release download ${TAG_NAME} -p "${TAG_NAME}.sha*" - - # echo "sha256sum=$(cat ${TAG_NAME}.sha256)" >> $GITHUB_OUTPUT - # echo "archive=https://github.com/${{ github.repository }}/archive/refs/tags/${TAG_NAME}.tar.gz" >> $GITHUB_OUTPUT - # env: - # GH_TOKEN: ${{ steps.app-token.outputs.token }} - name: Set up Homebrew id: set-up-homebrew uses: Homebrew/actions/setup-homebrew@master @@ -99,4 +102,79 @@ jobs: with: token: ${{ steps.app-token.outputs.token }} formulae: gomplate - fork: false + fork: true + # - name: Bump package + # run: brew bump --open-pr --formulae gomplate + # env: + # HOMEBREW_DEVELOPER: "1" + # HOMEBREW_GITHUB_API_TOKEN: ${{ steps.app-token.outputs.token }} + deploy-docker: + runs-on: ubuntu-latest + env: + # TAG_NAME: ${{ github.event.release.tag_name }} + TAG_NAME: v4.3.0 + steps: + - name: Set up QEMU + uses: docker/setup-qemu-action@v3.2.0 + - name: Set up Docker Buildx + id: buildx + uses: docker/setup-buildx-action@v3.8.0 + with: + version: v0.14.1 + driver-opts: | + image=moby/buildkit:buildx-stable-1 + network=host + - name: Available platforms + run: echo {{ `${{ steps.buildx.outputs.platforms }}` }} + - run: docker info && docker version + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Login to GHCR + uses: docker/login-action@v3.3.0 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Login to DockerHub + uses: docker/login-action@v3.3.0 + with: + # NOTE: DOCKERHUB_TOKEN and DOCKERHUB_USERNAME must be present in https://github.com/hairyhenderson/gomplate/settings + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: Build & Push + run: | + export srcrepo=ghcr.io/${{ github.repository}} + + make docker-multi COMMIT=${{ github.sha }} DOCKER_REPO=${srcrepo} BUILDX_ACTION=--push + + set -x + export repo=${srcrepo} + export git_tag=${TAG_NAME} + export major_version=${git_tag%\.*} + docker buildx imagetools create -t ${repo}:stable ${srcrepo}:latest + docker buildx imagetools create -t ${repo}:${git_tag} ${srcrepo}:latest + docker buildx imagetools create -t ${repo}:${major_version} ${srcrepo}:latest + + docker buildx imagetools create -t ${repo}:stable-alpine ${srcrepo}:alpine + docker buildx imagetools create -t ${repo}:${git_tag}-alpine ${srcrepo}:alpine + docker buildx imagetools create -t ${repo}:${major_version}-alpine ${srcrepo}:alpine + + # and now DockerHub (if we don't get rate-limited) + export repo=gomplate/gomplate + docker buildx imagetools create -t ${repo}:stable ${srcrepo}:latest + docker buildx imagetools create -t ${repo}:${git_tag} ${srcrepo}:latest + docker buildx imagetools create -t ${repo}:${major_version} ${srcrepo}:latest + + docker buildx imagetools create -t ${repo}:stable-alpine ${srcrepo}:alpine + docker buildx imagetools create -t ${repo}:${git_tag}-alpine ${srcrepo}:alpine + docker buildx imagetools create -t ${repo}:${major_version}-alpine ${srcrepo}:alpine + + export repo=hairyhenderon/gomplate + docker buildx imagetools create -t ${repo}:stable ${srcrepo}:latest + docker buildx imagetools create -t ${repo}:${git_tag} ${srcrepo}:latest + docker buildx imagetools create -t ${repo}:${major_version} ${srcrepo}:latest + + docker buildx imagetools create -t ${repo}:stable-alpine ${srcrepo}:alpine + docker buildx imagetools create -t ${repo}:${git_tag}-alpine ${srcrepo}:alpine + docker buildx imagetools create -t ${repo}:${major_version}-alpine ${srcrepo}:alpine diff --git a/packaging/alpine/APKBUILD.tmpl b/packaging/alpine/APKBUILD.tmpl new file mode 100644 index 000000000..388945975 --- /dev/null +++ b/packaging/alpine/APKBUILD.tmpl @@ -0,0 +1,38 @@ +# Maintainer: Dave Henderson +pkgname=gomplate +pkgver={{.version}} +pkgrel=0 +pkgdesc="A versatile Go template processor" +url="https://github.com/hairyhenderson/gomplate" +arch="all" +license="MIT" +depends="ca-certificates" +makedepends="go" +options="net" +source="$pkgname-$pkgver.tar.gz::https://github.com/hairyhenderson/gomplate/archive/v$pkgver.tar.gz" + +export GOFLAGS="$GOFLAGS -trimpath -modcacherw" +export GOCACHE="${GOCACHE:-"$srcdir/go-cache"}" +export GOTMPDIR="${GOTMPDIR:-"$srcdir"}" +export GOMODCACHE="${GOMODCACHE:-"$srcdir/go"}" + +build() { + # CGO needs to be able to be enabled for -buildmode=pie, setting it to an + # empty string is a workaround for now. + # See: https://gitlab.alpinelinux.org/alpine/aports/-/issues/15809 + make build \ + CGO_ENABLED= \ + VERSION="$pkgver" \ + COMMIT="unknown" +} + +check() { + # Note: make test (that runs go test -race) doesn't work. + go test -v +} + +package() { + install -D -m 755 bin/gomplate "$pkgdir"/usr/bin/gomplate +} + +sha512sums="{{.sha512}} gomplate-{{.version}}.tar.gz"