Skip to content

Commit dc7902e

Browse files
authored
Merge pull request #185 from devcontainers-extra/feat/feature-gh-release-template
feat(templates): add gh-release feature template
2 parents 98ed0a1 + f571228 commit dc7902e

17 files changed

Lines changed: 454 additions & 7 deletions
Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
name: Generate Feature from gh-release Template
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
ID:
7+
description: 'Feature identifier (e.g., akamai-cli)'
8+
required: true
9+
type: string
10+
Description:
11+
description: 'Feature description'
12+
required: true
13+
type: string
14+
Repository:
15+
description: 'GitHub repository in format "owner/repo" (e.g., akamai/cli)'
16+
required: true
17+
type: string
18+
BinaryNames:
19+
description: 'Binary names (comma-separated if multiple)'
20+
required: true
21+
type: string
22+
BinaryVersionCommands:
23+
description: 'Version check commands (comma-separated if multiple)'
24+
required: false
25+
type: string
26+
default: '--version'
27+
BinaryNonLatestVersions:
28+
description: 'Non-latest versions for testing (comma-separated if multiple)'
29+
required: true
30+
type: string
31+
32+
jobs:
33+
generate:
34+
runs-on: ubuntu-latest
35+
steps:
36+
- name: Checkout repository
37+
uses: actions/checkout@v6
38+
with:
39+
token: ${{ secrets.ARCHIVE_TOKEN }}
40+
41+
- name: Check if feature already exists
42+
run: |
43+
if [ -d "src/${{ inputs.ID }}" ] || [ -d "test/${{ inputs.ID }}" ]; then
44+
echo "❌ Feature '${{ inputs.ID }}' already exists!"
45+
echo "Please use a different feature ID or remove the existing feature first."
46+
exit 1
47+
fi
48+
echo "✅ Feature ID is available"
49+
50+
- name: Validate GitHub repository exists
51+
env:
52+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
53+
run: |
54+
if gh api repos/${{ inputs.Repository }} > /dev/null 2>&1; then
55+
echo "✅ Repository '${{ inputs.Repository }}' exists and is accessible"
56+
else
57+
echo "⚠️ Warning: Could not verify repository '${{ inputs.Repository }}'"
58+
echo "The repository might be private, not exist, or you don't have access to it."
59+
echo "Continuing with feature generation..."
60+
fi
61+
62+
- name: Download boilerplate
63+
run: |
64+
wget -q https://github.com/gruntwork-io/boilerplate/releases/download/v0.10.1/boilerplate_linux_amd64
65+
chmod +x boilerplate_linux_amd64
66+
67+
- name: Create vars.yml
68+
run: |
69+
cat > vars.yml << 'EOF'
70+
ID: ${{ inputs.ID }}
71+
Description: ${{ inputs.Description }}
72+
Repository: ${{ inputs.Repository }}
73+
BinaryNames: ${{ inputs.BinaryNames }}
74+
BinaryVersionCommands: ${{ inputs.BinaryVersionCommands }}
75+
BinaryNonLatestVersions: ${{ inputs.BinaryNonLatestVersions }}
76+
EOF
77+
echo "📝 Created vars.yml:"
78+
cat vars.yml
79+
80+
- name: Create branch for new feature
81+
run: |
82+
git config user.name "github-actions[bot]"
83+
git config user.email "github-actions[bot]@users.noreply.github.com"
84+
git checkout -b feature/${{ inputs.ID }}-init
85+
86+
- name: Generate feature files
87+
run: |
88+
echo "🔧 Generating feature files from templates/gh-release..."
89+
./boilerplate_linux_amd64 \
90+
--template-url templates/gh-release/ \
91+
--output-folder src/${{ inputs.ID }} \
92+
--var-file vars.yml \
93+
--non-interactive
94+
95+
- name: Generate test files
96+
run: |
97+
echo "🧪 Generating test files from templates/test..."
98+
./boilerplate_linux_amd64 \
99+
--template-url templates/test/ \
100+
--output-folder test/${{ inputs.ID }} \
101+
--var-file vars.yml \
102+
--non-interactive
103+
104+
- name: Commit changes
105+
run: |
106+
git add -A
107+
git commit -m "feat(${{ inputs.ID }}): init
108+
109+
Generated using boilerplate templates."
110+
111+
- name: Push changes
112+
run: git push origin feature/${{ inputs.ID }}-init
113+
114+
- name: Create Pull Request
115+
env:
116+
GH_TOKEN: ${{ secrets.ARCHIVE_TOKEN }}
117+
run: |
118+
gh pr create \
119+
--title "feat(${{ inputs.ID }}): init" \
120+
--body "## New Feature: \`${{ inputs.ID }}\`
121+
122+
**Description:** ${{ inputs.Description }}
123+
124+
**Repository:** [${{ inputs.Repository }}](https://github.com/${{ inputs.Repository }})
125+
126+
**Binaries:** \`${{ inputs.BinaryNames }}\`
127+
128+
**Version Commands:** \`${{ inputs.BinaryVersionCommands }}\`
129+
130+
**Test Versions:** \`${{ inputs.BinaryNonLatestVersions }}\`
131+
132+
---
133+
134+
This PR was automatically generated using the boilerplate templates.
File renamed without changes.

‎templates/bak/test/scenarios.json‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"test_debian": {
3+
"image": "mcr.microsoft.com/devcontainers/base:debian",
4+
"features": {
5+
"<id>": {}
6+
}
7+
},
8+
"test_specific_version": {
9+
"image": "mcr.microsoft.com/devcontainers/base:debian",
10+
"features": {
11+
"<id>": {
12+
"version": "x.y.z"
13+
}
14+
}
15+
}
16+
}

‎templates/bak/test/test.sh‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/usr/bin/env bash
2+
3+
set -e
4+
5+
source dev-container-features-test-lib
6+
7+
check "something is installed" something --version
8+
9+
reportResults

‎templates/bak/test/test_debian.sh‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/usr/bin/env bash
2+
3+
set -e
4+
5+
source dev-container-features-test-lib
6+
7+
check "something is installed" something --version
8+
9+
reportResults
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/usr/bin/env bash
2+
3+
set -e
4+
5+
source dev-container-features-test-lib
6+
7+
check "something version is equal to x.y.z" sh -c "something --version | grep 'x.y.z'"
8+
9+
reportResults
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
variables:
2+
- name: ID
3+
description: The unique identifier for the feature (e.g., akamai-cli).
4+
5+
- name: Description
6+
description: A brief description of the feature.
7+
8+
- name: Repository
9+
description: The GitHub repository in the format "owner/repo" (e.g., akamai/cli).
10+
11+
- name: BinaryNames
12+
description: The names of the binaries to install from the release (comma-separated if multiple).
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"id": "{{.ID}}",
3+
"version": "1.0.0",
4+
"name": "{{.ID}} (via Github Releases)",
5+
"documentationURL": "http://github.com/devcontainers-extra/features/tree/main/src/{{.ID}}",
6+
"description": "{{.Description}}",
7+
"options": {
8+
"version": {
9+
"default": "latest",
10+
"description": "Select the version to install.",
11+
"proposals": [
12+
"latest"
13+
],
14+
"type": "string"
15+
}
16+
},
17+
"installsAfter": []
18+
}

0 commit comments

Comments
 (0)