From 6f658488ee099a14d0f3597e2416bfe6e97a8b66 Mon Sep 17 00:00:00 2001 From: Alexander Sharov Date: Wed, 5 Jun 2024 19:34:39 +0300 Subject: [PATCH] feat: add snap support Signed-off-by: Alexander Sharov --- .github/workflows/publish-snap.yml | 65 ------------------------------ .github/workflows/release.yml | 33 +++++++++++++++ .goreleaser.yml | 43 ++++++++++++++++++++ 3 files changed, 76 insertions(+), 65 deletions(-) delete mode 100644 .github/workflows/publish-snap.yml diff --git a/.github/workflows/publish-snap.yml b/.github/workflows/publish-snap.yml deleted file mode 100644 index f89b7e25..00000000 --- a/.github/workflows/publish-snap.yml +++ /dev/null @@ -1,65 +0,0 @@ ---- -name: "Snapcraft Release Pipeline" - -on: - release: - types: [released] - -jobs: - build: - runs-on: ubuntu-latest - - steps: - - name: Checkout - uses: actions/checkout@v4 - - - uses: snapcore/action-build@v1 - id: build - - - uses: snapcore/action-publish@v1 - env: - SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.STORE_LOGIN }} - with: - snap: ${{ steps.build.outputs.snap }} - release: edge - -# - uses: snapcore/action-publish@v1 -# with: -# store_login: ${{ secrets.STORE_LOGIN }} -# snap: ${{ steps.build.outputs.snap }} -# release: edge - - - - - name: Update chocolatey checksums - run: | - echo "[INFO] Wait until all artefacts will be uploaded" - sleep 300 - - release_tag=${{ github.event.release.tag_name }} - release_version="${release_tag#v}" - - echo "[INFO] Download release's checksums" - curl \ - -SsL \ - -o /tmp/checksums.txt \ - https://github.com/tofuutils/tenv/releases/download/${release_tag}/tenv_${release_tag}_checksums.txt - - echo "[INFO] Update chocolateyinstall.ps1" - choco_url="https://github.com/tofuutils/tenv/releases/download/${release_tag}/tenv_${release_tag}_Windows_i386.zip" - choco_url64="https://github.com/tofuutils/tenv/releases/download/${release_tag}/tenv_${release_tag}_Windows_x86_64.zip" - choco_sum="$(grep "tenv_${release_tag}_Windows_i386.zip" /tmp/checksums.txt | cut -d ' ' -f 1 | tr -d '\n')" - choco_sum64="$(grep "tenv_${release_tag}_Windows_x86_64.zip" /tmp/checksums.txt | cut -d ' ' -f 1 | tr -d '\n')" - - sed -i "s~\$url = '.*'~\$url = '${choco_url}'~g" tenv/tools/chocolateyinstall.ps1 - sed -i "s~\$url64 = '.*'~\$url64 = '${choco_url64}'~g" tenv/tools/chocolateyinstall.ps1 - sed -i "s~\$checksum = '.*'~\$checksum = '${choco_sum}'~g" tenv/tools/chocolateyinstall.ps1 - sed -i "s~\$checksum64 = '.*'~\$checksum64 = '${choco_sum64}'~g" tenv/tools/chocolateyinstall.ps1 - - echo "[INFO] Push changes back to git" - git config user.name tofuutils - git config user.email tofuutils@github.com - git add -A - git commit -m "Chocolatey scripts update for tenv version ${release_tag}" - git tag -a ${release_version} -m "${release_version}" - git push origin --tags main \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index e30b6472..482ad343 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -29,6 +29,29 @@ jobs: mv cosign-linux-amd64 /usr/local/bin/cosign chmod +x /usr/local/bin/cosign + - name: Import GPG key + run: | + GPG_KEY_FILE=/tmp/signing-key.gpg + echo "${{ secrets.GPG_PRIVATE_KEY }}" | base64 --decode > "${GPG_KEY_FILE}" + + echo "${{ secrets.GPG_PRIVATE_KEY }}" | base64 --decode | gpg --import + GPG_FINGERPRINT=$(gpg --list-secret-keys --keyid-format LONG | awk '/^sec/{sub(/.*\//, "", $2); print $2; exit}') + + echo "GPG_FINGERPRINT=${GPG_FINGERPRINT}" >>"${GITHUB_ENV}" + echo "GPG_KEY_FILE=${GPG_KEY_FILE}" >> "${GITHUB_ENV}" + env: + GPG_TTY: /dev/ttys000 # Set the GPG_TTY to avoid issues with pinentry + + - name: Setup snapcraft + run: | + sudo snap install snapcraft --classic --channel=7.x/stable + + # See https://github.com/goreleaser/goreleaser/issues/1715 + mkdir -p "$HOME/.cache/snapcraft/download" + mkdir -p "$HOME/.cache/snapcraft/stage-packages" + env: + SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.SNAPCRAFT_STORE_TOKEN }} + - name: Run GoReleaser uses: goreleaser/goreleaser-action@v5 with: @@ -37,6 +60,8 @@ jobs: args: release --clean -f ${{ vars.GORELEASER_CONFIG_PATH }} env: GITHUB_TOKEN: ${{ secrets.TENV_GITHUB_TOKEN }} + SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.SNAPCRAFT_STORE_TOKEN }} + docker-ghcr: name: 'Build and release docker image to github container registry' runs-on: ubuntu-latest @@ -46,16 +71,20 @@ jobs: steps: - name: Checkout uses: actions/checkout@v4 + - name: Set up QEMU uses: docker/setup-qemu-action@v3 + - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 + - name: Login to GitHub Container Registry uses: docker/login-action@v3 with: registry: ghcr.io username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} + - name: Build and push docker image uses: docker/build-push-action@v5 with: @@ -72,16 +101,20 @@ jobs: steps: - name: Checkout uses: actions/checkout@v4 + - name: Set up QEMU uses: docker/setup-qemu-action@v3 + - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 + - name: Login to GitHub Container Registry uses: docker/login-action@v3 with: registry: ${{ env.registry_url }} username: ${{ secrets.REGISTRY_USER }} password: ${{ secrets.REGISTRY_PASSWORD }} + - name: Build and push docker image uses: docker/build-push-action@v5 with: diff --git a/.goreleaser.yml b/.goreleaser.yml index d81d9ae6..10d25046 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -238,6 +238,13 @@ checksum: name_template: "{{ .ProjectName }}_{{ .Tag }}_checksums.txt" algorithm: sha256 +signs: + - artifacts: all + signature: "${artifact}.gpgsig" + id: gpg + cmd: gpg + args: [ "--batch", "-u", "{{ .Env.GPG_FINGERPRINT }}", "--output", "${signature}", "--detach-sign", "${artifact}" ] + nfpms: - file_name_template: "{{ .ProjectName }}_{{- .Tag }}_{{ .Arch }}" maintainer: "https://github.com/dvaumoron" @@ -272,6 +279,42 @@ nfpms: pkgbase: tenv packager: tofuutils +snapcrafts: + - name: tenv + publish: true + summary: OpenTofu, Terraform, Terragrunt, and Atmos version manager, written in Go. + description: | + tenv is a versatile version manager for OpenTofu, Terraform, Terragrunt and Atmos, written in Go. + Our tool simplifies the complexity of handling different versions of these powerful tools, + ensuring developers and DevOps professionals + can focus on what matters most - building and deploying efficiently. + disable: 'false' + channel_templates: + - 'latest/stable' + grade: 'stable' + confinement: classic + license: Apache-2.0 + base: core22 + apps: + tenv: + command: tenv + aliases: [ tenv ] + tofu: + command: tofu + aliases: [ tofu ] + terraform: + command: terraform + aliases: [ terraform ] + terragrunt: + command: terragrunt + aliases: [ terragrunt ] + tf: + command: tf + aliases: [ tf ] + atmos: + command: atmos + aliases: [ atmos ] + # chocolateys: # - name: tenv # # Empty means all IDs.