Skip to content

Commit 709bcdb

Browse files
committed
Add dflook/tofu actions
1 parent 2dc0e8d commit 709bcdb

File tree

60 files changed

+4089
-360
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+4089
-360
lines changed

.github/workflows/release-test.yaml

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
1-
name: Release
1+
name: Test Release
22

33
on:
4-
workflow_dispatch:
5-
inputs:
6-
tag_name:
7-
description: "Tag to push"
8-
required: true
4+
- push
95

106
jobs:
117
image:
@@ -17,6 +13,11 @@ jobs:
1713
- name: Checkout
1814
uses: actions/checkout@v3
1915

16+
- name: Check tofu actions are up to date
17+
run: |
18+
python3 tofu/tofuize.py
19+
git diff --exit-code
20+
2021
- name: Registry login
2122
env:
2223
GITHUB_TOKEN: ${{ secrets.RELEASE_GITHUB_TOKEN }}
@@ -31,7 +32,7 @@ jobs:
3132
- name: Build action image
3233
id: image_build
3334
run: |
34-
RELEASE_TAG="${{ github.event.inputs.tag_name }}"
35+
RELEASE_TAG="tofu.0.0"
3536
3637
docker buildx build \
3738
--build-arg FETCH_CHECKSUMS=yes \
@@ -48,7 +49,9 @@ jobs:
4849
4950
- name: Release actions
5051
run: |
51-
export RELEASE_TAG="${{ github.event.inputs.tag_name }}"
52+
set -x
53+
54+
export RELEASE_TAG="tofu.0.0"
5255
export major=$(echo $RELEASE_TAG | cut -d. -f1)
5356
export minor=$(echo $RELEASE_TAG | cut -d. -f2)
5457
@@ -62,7 +65,7 @@ jobs:
6265
cp $GITHUB_WORKSPACE/.github/FUNDING.yml $HOME/$action/.github/FUNDING.yml
6366
}
6467
65-
for action in $(cd $GITHUB_WORKSPACE && find . -name action.yaml -printf "%h\n" | sed 's/^.\///'); do
68+
action=tofu-version
6669
6770
if git clone https://dflook:[email protected]/dflook/$action.git "$HOME/$action"; then
6871
echo "Releasing dflook/$action@$RELEASE_TAG"
@@ -80,7 +83,7 @@ jobs:
8083
git -C "$HOME/$action" push --force --tags
8184
8285
# git tags that use GitHub Container Registry for the image
83-
git -C "$HOME/$action" checkout ghcr
86+
git -C "$HOME/$action" checkout ghcr || git -C "$HOME/$action" checkout -b ghcr
8487
prepare_release
8588
sed -i 's| image:.*| image: docker://ghcr.io/dflook/terraform-github-actions@${{ steps.image_build.outputs.digest }}|' $HOME/$action/action.yaml
8689
@@ -89,12 +92,10 @@ jobs:
8992
git -C "$HOME/$action" tag --force -a -m"$RELEASE_TAG" "$RELEASE_TAG-ghcr"
9093
git -C "$HOME/$action" tag --force -a -m"$RELEASE_TAG" "$major-ghcr"
9194
git -C "$HOME/$action" tag --force -a -m"$RELEASE_TAG" "$major.$minor-ghcr"
92-
git -C "$HOME/$action" push --force
95+
git -C "$HOME/$action" push --set-upstream origin ghcr --force
9396
git -C "$HOME/$action" push --force --tags
9497
95-
# For testing, only release one action
96-
exit 0
9798
else
98-
echo "Skipping $action"
99+
echo "Skipping dflook/$action"
99100
fi
100-
done
101+

.github/workflows/release.yaml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ jobs:
2020
- name: Checkout
2121
uses: actions/checkout@v3
2222

23+
- name: Check tofu actions are up to date
24+
run: |
25+
python3 tofu/tofuize.py
26+
git diff --exit-code
27+
2328
- name: Registry login
2429
env:
2530
GITHUB_TOKEN: ${{ secrets.RELEASE_GITHUB_TOKEN }}
@@ -83,7 +88,7 @@ jobs:
8388
git -C "$HOME/$action" push --force --tags
8489
8590
# git tags that use GitHub Container Registry for the image
86-
git -C "$HOME/$action" checkout ghcr
91+
git -C "$HOME/$action" checkout ghcr || git -C "$HOME/$action" checkout -b ghcr
8792
prepare_release
8893
sed -i 's| image:.*| image: docker://ghcr.io/dflook/terraform-github-actions@${{ steps.image_build.outputs.digest }}|' $HOME/$action/action.yaml
8994
@@ -92,7 +97,7 @@ jobs:
9297
git -C "$HOME/$action" tag --force -a -m"$RELEASE_TAG" "$RELEASE_TAG-ghcr"
9398
git -C "$HOME/$action" tag --force -a -m"$RELEASE_TAG" "$major-ghcr"
9499
git -C "$HOME/$action" tag --force -a -m"$RELEASE_TAG" "$major.$minor-ghcr"
95-
git -C "$HOME/$action" push --force
100+
git -C "$HOME/$action" push --set-upstream origin ghcr --force
96101
git -C "$HOME/$action" push --force --tags
97102
98103
# Create the github release
@@ -106,6 +111,6 @@ jobs:
106111
"https://api.github.com/repos/dflook/$action/releases"
107112
108113
else
109-
echo "Skipping $action"
114+
echo "Skipping dflook/$action"
110115
fi
111116
done

image/src/terraform_version/__main__.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ def determine_version(inputs: InitInputs, cli_config_path: Path, actions_env: Ac
9090
sys.stdout.write(f'Using the same {version.product} version that wrote the existing remote state file\n')
9191
return version
9292

93-
sys.stdout.write(f'Version not specified, using the latest version\n')
93+
sys.stdout.write(f'Version not specified, using the latest release version\n')
9494
return latest_non_prerelease_version(versions)
9595

9696

@@ -136,6 +136,14 @@ def main() -> None:
136136
cast(ActionsEnv, os.environ),
137137
cast(GithubEnv, os.environ)
138138
)
139+
140+
if version is None:
141+
if 'OPENTOFU' in os.environ:
142+
sys.stderr.write('No release version of OpenTofu found. Try specifying a pre-release version, e.g. OPENTOFU_VERSION=1.6.0-alpha3\n')
143+
else:
144+
sys.stderr.write('No eligible versions found\n')
145+
sys.exit(1)
146+
139147
switch(version)
140148

141149
except DownloadError as download_error:

image/src/terraform_version/get_checksums.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
import sys
33
from pathlib import Path
44

5+
from opentofu.versions import get_opentofu_versions
6+
from opentofu.download import get_checksums as get_opentofu_checksums
57
from terraform.download import get_checksums
68
from terraform.versions import get_terraform_versions
79

@@ -13,5 +15,9 @@ def main() -> None:
1315
for version in get_terraform_versions():
1416
if version.pre_release:
1517
continue
16-
sys.stdout.write(f'Getting checksums for {version}\n')
18+
sys.stdout.write(f'Getting checksums for Terraform {version}\n')
1719
get_checksums(version, checksum_dir)
20+
21+
for version in get_opentofu_versions():
22+
sys.stdout.write(f'Getting checksums for OpenTofu {version}\n')
23+
get_opentofu_checksums(version, checksum_dir)

0 commit comments

Comments
 (0)