Skip to content

Commit af68104

Browse files
committed
Initial commit
1 parent 3e51c35 commit af68104

File tree

7 files changed

+100
-0
lines changed

7 files changed

+100
-0
lines changed

.envrc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
asdf install
+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: Build and Publish
2+
on:
3+
push:
4+
branches:
5+
- main
6+
pull_request:
7+
jobs:
8+
build_and_publish:
9+
name: "Create Pkl package, tag and release"
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Checkout code
13+
uses: actions/checkout@v3
14+
with:
15+
fetch-depth: 0
16+
17+
- name: Install tools
18+
uses: asdf-vm/actions/install@v3
19+
20+
- name: Determine version bump level
21+
id: determine_bump_level
22+
run: echo "level=patch" >> $GITHUB_ENV
23+
24+
- name: Get Current Version
25+
id: get_version
26+
run: echo "current_version=$(git describe --tags --abbrev=0)" >> $GITHUB_ENV
27+
28+
- name: Calculate next version
29+
id: get_semver
30+
uses: rickstaa/action-get-semver@v1
31+
with:
32+
bump_level: ${{ env.level }}
33+
34+
- name: Set Project Version Output
35+
id: project_version
36+
run: |
37+
echo "project_version=${{ steps.get_semver.outputs.next_version }}" >> $GITHUB_ENV
38+
echo "project_version_without_v=$(echo ${{ steps.get_semver.outputs.next_version }} | tr -d 'v')" >> $GITHUB_ENV
39+
40+
- name: Substitute version
41+
run: |
42+
sed -i "s/0.0.0/${{ steps.project_version.outputs.project_version_without_v }}/g" PklProject
43+
44+
- name: Build Pkl package
45+
run: pkl project package
46+
47+
- name: Apply tag
48+
run : git tag ${{ steps.project_version.outputs.project_version }}
49+
if: github.event.name == 'push' && github.event.ref == 'refs/heads/master'
50+
51+
- name: Release
52+
uses: softprops/action-gh-release@v2
53+
if: github.event_name == 'push' && github.event.ref == 'refs/heads/master'
54+
with:
55+
tag_name: ${{ steps.project_version.outputs.project_version }}
56+
files: .out/terraform@${{env.project_version_without_v}}/*
57+
58+
- name: Push tag
59+
if: github.event_name == 'push' && github.event.ref == 'refs/heads/master'
60+
run: git push origin ${{ steps.project_version.outputs.project_version }}

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.out/
2+
.pkl-lsp/

.tool-versions

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pkl 0.28.1

Backends.pkl

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
class S3BackendConfig {
2+
bucket: String
3+
region: String
4+
key: String
5+
use_lockfile: Boolean = true
6+
}
7+
8+
class LocalBackendConfig {
9+
path: String
10+
}

PklProject

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
amends "pkl:Project"
2+
3+
package {
4+
name = "terraform"
5+
baseUri = "package://github.com/infrablocks/pkl-\(name)/"
6+
version = "0.0.0"
7+
packageZipUrl = "https://github.com/infrablocks/pkl-\(name)/releases/download/v\(version)/pkl-\(name)@\(version).zip"
8+
}

TfVarsRenderer.pkl

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import "Backends.pkl"
2+
3+
class TfVarsRenders extends ValueRenderer {
4+
function renderDocument(value: Any): String = renderValue(value)
5+
function renderValue(value: Any): String =
6+
if (value is String)
7+
"\"" + value + "\""
8+
else if (value is Boolean)
9+
if (value) "true" else "false"
10+
else if (value is Dynamic)
11+
renderDynamic(value)
12+
else if (value is Object)
13+
renderDynamic((values as Object).toDynamic())
14+
else
15+
"ERROR - don't know how to render: " + value
16+
function renderDynamic(object: Dynamic): String =
17+
object.toMap().entries.map((el) -> el.key + " = " + renderValue(el.value)).join("\n")
18+
}

0 commit comments

Comments
 (0)