Skip to content
This repository was archived by the owner on Sep 30, 2025. It is now read-only.

Commit e7b7433

Browse files
Merge pull request #28 from firehydrant/js/release-tagging-action
Add tag release action
2 parents 3b72d17 + 7533f34 commit e7b7433

File tree

2 files changed

+213
-0
lines changed

2 files changed

+213
-0
lines changed

.github/workflows/tag_release.yaml

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
name: Tag Release
2+
permissions:
3+
contents: write
4+
on:
5+
push:
6+
branches:
7+
- main
8+
paths:
9+
- 'internal/**'
10+
workflow_dispatch:
11+
inputs:
12+
set_version:
13+
description: optionally set a specific SDK version
14+
type: string
15+
16+
jobs:
17+
check_and_tag:
18+
runs-on: ubuntu-latest
19+
steps:
20+
- name: Checkout code
21+
uses: actions/checkout@v4
22+
with:
23+
fetch-depth: 0
24+
25+
- name: Calculate next version
26+
id: version
27+
run: |
28+
new_version=""
29+
30+
# If manual dispatch with set_version, use that (highest priority)
31+
if [ -n "${{ github.event.inputs.set_version }}" ]; then
32+
new_version="${{ github.event.inputs.set_version }}"
33+
# Add 'v' prefix if not present
34+
if [[ ! $new_version =~ ^v ]]; then
35+
new_version="v$new_version"
36+
fi
37+
echo "Using manual version: $new_version"
38+
# If push event, try to extract version from PR title
39+
elif [ "${{ github.event_name }}" == "push" ]; then
40+
# Get the PR title from the merge commit message
41+
commit_message=$(git log -1 --format='%s')
42+
echo "Commit message: $commit_message"
43+
44+
# Extract version from PR title pattern "chore: 🐝 Update SDK - Generate X.X.X"
45+
if [[ $commit_message =~ Generate\ ([0-9]+\.[0-9]+\.[0-9]+) ]]; then
46+
extracted_version="${BASH_REMATCH[1]}"
47+
new_version="v$extracted_version"
48+
echo "Extracted version from PR title: $new_version"
49+
else
50+
echo "❌ Could not extract version from commit message"
51+
echo "Expected format: 'chore: 🐝 Update SDK - Generate X.X.X'"
52+
echo "Actual message: $commit_message"
53+
fi
54+
fi
55+
56+
# Validate that we have a version
57+
if [ -z "$new_version" ]; then
58+
echo "❌ No version could be determined. Workflow will exit."
59+
echo "Please either:"
60+
echo " 1. Use workflow_dispatch with set_version input, or"
61+
echo " 2. Ensure PR title contains 'Generate X.X.X' pattern"
62+
exit 1
63+
fi
64+
65+
echo "✅ Final version: $new_version"
66+
echo "new_version=$new_version" >> $GITHUB_OUTPUT
67+
68+
- name: Configure Git
69+
run: |
70+
git config user.name "github-actions[bot]"
71+
git config user.email "github-actions[bot]@users.noreply.github.com"
72+
73+
- name: Create and push tag
74+
run: |
75+
new_version="${{ steps.version.outputs.new_version }}"
76+
echo "Creating tag: $new_version"
77+
78+
# Create annotated tag with message
79+
git tag -a "$new_version" -m "Release $new_version - Updated Terraform provider"
80+
81+
# Push the tag
82+
git push origin "$new_version"
83+
84+
echo "Successfully created and pushed tag: $new_version"

scripts/Readme.md

Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,135 @@ This pipeline is typically run as part of a GitHub Action:
221221
222222
The generated overlay is then used by Speakeasy to create the Terraform provider.
223223
224+
## Release Process
225+
226+
Our automated release process ensures consistent versioning and reliable publishing of the Terraform provider.
227+
228+
### Overview
229+
230+
The release process consists of three main GitHub Actions workflows:
231+
232+
1. **SDK Generation** (`sdk_generation.yaml`) - Daily automated provider generation
233+
2. **Tag Release** (`tag_release.yaml`) - Creates release tags when provider code changes
234+
3. **Release Terraform Provider** (`release.yaml`) - Publishes the provider to registries
235+
236+
### Automated Release Flow
237+
238+
```mermaid
239+
flowchart TD
240+
A [Daily: SDK Generation Workflow] --> [Speakeasy Bot Opens PR]
241+
B --> Merge PR to main
242+
C --> {PR Contains /internal Changes?}
243+
C -->|Yes| [Tag Release Workflow Triggered]
244+
C -->|No| [No release]
245+
D --> [Extract Version from PR Title]
246+
E --> [Create Git Tag]
247+
F --> [Release Workflow Triggered]
248+
G --> [GoReleaser Publishes Provider]
249+
```
250+
251+
### Workflow Details
252+
253+
#### 1. SDK Generation (`sdk_generation.yaml`)
254+
**Triggers:** Daily at midnight, manual dispatch
255+
**Purpose:** Generate updated provider from latest OpenAPI spec
256+
257+
**Process:**
258+
- Fetches latest OpenAPI spec from developers repo
259+
- Runs normalization and overlay scripts
260+
- Generates provider via Speakeasy
261+
- Speakeasy bot opens PR with changes
262+
263+
#### 2. Tag Release (`tag_release.yaml`)
264+
**Triggers:** Push to main with `/internal/**` changes, manual dispatch
265+
**Purpose:** Create release tags with proper versioning
266+
267+
**Version Sources (in priority order):**
268+
1. **Manual dispatch** with `set_version` input
269+
2. **Speakeasy PR title** - Extracts version from pattern: `"chore: 🐝 Update SDK - Generate X.X.X"`
270+
3. **Workflow fails** if no version found (no auto-increment to prevent wrong versions)
271+
272+
**Process:**
273+
- Detects version from PR title or manual input
274+
- Creates annotated Git tag (e.g., `v0.2.7`)
275+
- Pushes tag to repository
276+
277+
#### 3. Release Terraform Provider (`release.yaml`)
278+
**Triggers:** Git tag creation (`v*` pattern), manual dispatch
279+
**Purpose:** Publish provider to Terraform Registry
280+
281+
**Process:**
282+
- Triggered automatically when tag is created
283+
- Runs GoReleaser to build and publish provider
284+
- Creates GitHub release with assets
285+
- Publishes to Terraform Registry
286+
287+
### Manual Release Process
288+
289+
For manual releases or hotfixes:
290+
291+
1. **Direct tag creation:**
292+
```bash
293+
git tag v0.2.8
294+
git push origin v0.2.8
295+
```
296+
297+
2. **Via workflow dispatch:**
298+
- Go to Actions → "Tag Release" workflow
299+
- Click "Run workflow"
300+
- Set `set_version` to desired version (e.g., `0.2.8`)
301+
- Run workflow
302+
303+
### Version Management
304+
305+
- **Current version scheme:** `v0.2.X` (semantic versioning)
306+
- **Speakeasy determines versions** based on API changes
307+
- **No auto-increment** to prevent accidental releases
308+
- **Version extraction** from PR titles ensures accuracy
309+
310+
### Troubleshooting
311+
312+
#### Tag Mismatch Errors
313+
If you see errors like "git tag v0.2.6 was not made against commit...", fix with:
314+
```bash
315+
git tag -d v0.2.6
316+
git push origin :refs/tags/v0.2.6
317+
git tag v0.2.6
318+
git push origin v0.2.6
319+
```
320+
321+
#### Missing Version in PR
322+
If the Tag Release workflow fails due to missing version:
323+
- Check PR title follows format: `"chore: 🐝 Update SDK - Generate X.X.X"`
324+
- Use manual dispatch with `set_version` as fallback
325+
326+
#### Release Workflow Fails
327+
- Verify tag exists and points to correct commit
328+
- Check GitHub tokens and secrets are configured
329+
- Ensure GoReleaser configuration is valid
330+
331+
### Testing Release Process
332+
333+
To test the release process safely:
334+
335+
1. **Create test branch:**
336+
```bash
337+
git checkout -b test-release
338+
```
339+
340+
2. **Modify tag workflow** to trigger on test branch
341+
3. **Use dry-run mode** to validate without creating actual tags
342+
4. **Test version extraction** with sample commit messages
343+
344+
### Prerequisites
345+
346+
Ensure these secrets are configured in GitHub:
347+
- `GITHUB_TOKEN` (automatic)
348+
- `terraform_gpg_private_key` (for signing)
349+
- `terraform_gpg_passphrase` (for signing)
350+
- `FH_OPS_SSH_KEY` (for accessing developers repo)
351+
- `SPEAKEASY_API_KEY` (for SDK generation)
352+
224353
## Provider Local Testing
225354

226355
After `speakeasy run` has successfully completed.

0 commit comments

Comments
 (0)