Skip to content

Commit eff1ea8

Browse files
committed
feat: add snapcraft support
1 parent 64a9d2c commit eff1ea8

2 files changed

Lines changed: 121 additions & 0 deletions

File tree

.github/workflows/snap.yml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
---
2+
name: "Snapcraft Release Pipeline"
3+
4+
on:
5+
release:
6+
types: [released]
7+
8+
jobs:
9+
build:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Checkout
14+
uses: actions/checkout@v4
15+
16+
- uses: snapcore/action-build@v1
17+
id: build
18+
19+
- uses: snapcore/action-publish@v1
20+
env:
21+
SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.STORE_LOGIN }}
22+
with:
23+
snap: ${{ steps.build.outputs.snap }}
24+
release: edge
25+
26+
# - uses: snapcore/action-publish@v1
27+
# with:
28+
# store_login: ${{ secrets.STORE_LOGIN }}
29+
# snap: ${{ steps.build.outputs.snap }}
30+
# release: edge
31+
32+
33+
34+
- name: Update chocolatey checksums
35+
run: |
36+
echo "[INFO] Wait until all artefacts will be uploaded"
37+
sleep 300
38+
39+
release_tag=${{ github.event.release.tag_name }}
40+
release_version="${release_tag#v}"
41+
42+
echo "[INFO] Download release's checksums"
43+
curl \
44+
-SsL \
45+
-o /tmp/checksums.txt \
46+
https://github.com/tofuutils/tenv/releases/download/${release_tag}/tenv_${release_tag}_checksums.txt
47+
48+
echo "[INFO] Update chocolateyinstall.ps1"
49+
choco_url="https://github.com/tofuutils/tenv/releases/download/${release_tag}/tenv_${release_tag}_Windows_i386.zip"
50+
choco_url64="https://github.com/tofuutils/tenv/releases/download/${release_tag}/tenv_${release_tag}_Windows_x86_64.zip"
51+
choco_sum="$(grep "tenv_${release_tag}_Windows_i386.zip" /tmp/checksums.txt | cut -d ' ' -f 1 | tr -d '\n')"
52+
choco_sum64="$(grep "tenv_${release_tag}_Windows_x86_64.zip" /tmp/checksums.txt | cut -d ' ' -f 1 | tr -d '\n')"
53+
54+
sed -i "s~\$url = '.*'~\$url = '${choco_url}'~g" tenv/tools/chocolateyinstall.ps1
55+
sed -i "s~\$url64 = '.*'~\$url64 = '${choco_url64}'~g" tenv/tools/chocolateyinstall.ps1
56+
sed -i "s~\$checksum = '.*'~\$checksum = '${choco_sum}'~g" tenv/tools/chocolateyinstall.ps1
57+
sed -i "s~\$checksum64 = '.*'~\$checksum64 = '${choco_sum64}'~g" tenv/tools/chocolateyinstall.ps1
58+
59+
echo "[INFO] Push changes back to git"
60+
git config user.name tofuutils
61+
git config user.email tofuutils@github.com
62+
git add -A
63+
git commit -m "Chocolatey scripts update for tenv version ${release_tag}"
64+
git tag -a ${release_version} -m "${release_version}"
65+
git push origin --tags main

snap/snapcraft.yaml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
2+
3+
name: tenv
4+
summary: Version manager for OpenTofu, Terraform and Terragrunt, written in Go.
5+
description: |
6+
tenv is a versatile version manager for [OpenTofu](https://opentofu.org), [Terraform](https://www.terraform.io/) and [Terragrunt](https://terragrunt.gruntwork.io/),
7+
written in Go. Our tool simplifies the complexity of handling different versions of these powerful tools,
8+
ensuring developers and DevOps professionals can focus on what matters most - building and deploying efficiently.
9+
10+
tenv is a successor of [tofuenv](https://github.com/tofuutils/tofuenv) and [tfenv](https://github.com/tfutils/tfenv).
11+
adopt-info: tenv
12+
version: git
13+
base: core22
14+
confinement: devmode #strict
15+
parts:
16+
tenv:
17+
plugin: go
18+
source: .
19+
build-snaps: [ go ]
20+
build-packages: [ pkg-config, libzstd-dev ]
21+
build-environment:
22+
- CGO_ENABLED: 0
23+
- CGO_LDFLAGS_ALLOW: ".*"
24+
# tenv:
25+
# plugin: go
26+
# source-type: git
27+
# source: https://github.com/get-woke/woke
28+
# override-pull: |
29+
# snapcraftctl pull
30+
# snapcraftctl set-version \
31+
# "$(git describe --long --tags --always --match=v*.*.* | sed 's/v//')"
32+
apps:
33+
tenv:
34+
command: cmd/tenv
35+
plugs:
36+
- home
37+
- dot-config-woke
38+
- network
39+
- removable-media
40+
golang-classic-example:
41+
command: bin/main
42+
43+
grade: devel #stable
44+
architectures:
45+
- build-on: amd64
46+
- build-on: armhf
47+
- build-on: arm64
48+
49+
#plugs:
50+
# dot-config-woke:
51+
# interface: personal-files
52+
# read:
53+
# - $HOME/.config/woke.yaml
54+
# - $HOME/.config/woke.yml
55+
# - $HOME/.woke.yaml
56+
# - $HOME/.woke.yml

0 commit comments

Comments
 (0)