-
Notifications
You must be signed in to change notification settings - Fork 0
87 lines (74 loc) · 2.25 KB
/
release.yml
File metadata and controls
87 lines (74 loc) · 2.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
name: Release
on:
push:
tags:
- "v*.*.*"
permissions:
contents: write
packages: write
env:
TF_VERSION: "1.11.3"
jobs:
# -----------------------------------------------------------------------
# Validate before release
# -----------------------------------------------------------------------
validate:
name: Pre-Release Validation
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Terraform
uses: hashicorp/setup-terraform@v3
with:
terraform_version: ${{ env.TF_VERSION }}
- name: Format Check
run: terraform fmt -check -recursive
- name: Validate Module
run: |
terraform init -backend=false
terraform validate
- name: Run Tests
run: |
terraform init -backend=false
terraform test
# -----------------------------------------------------------------------
# Create GitHub Release
# -----------------------------------------------------------------------
release:
name: Create Release
runs-on: ubuntu-latest
needs: validate
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get version from tag
id: version
run: echo "version=${GITHUB_REF_NAME#v}" >> "$GITHUB_OUTPUT"
- name: Create module archive
run: |
MODULE_NAME=$(basename "$GITHUB_REPOSITORY")
tar -czf "${MODULE_NAME}-${{ steps.version.outputs.version }}.tar.gz" \
--exclude='.git' \
--exclude='.github' \
--exclude='tests' \
--exclude='scripts' \
--exclude='.chglog' \
--exclude='Makefile' \
--exclude='.pre-commit-config.yaml' \
--exclude='.editorconfig' \
--exclude='.trivyignore' \
.
- name: Generate checksums
run: |
MODULE_NAME=$(basename "$GITHUB_REPOSITORY")
sha256sum "${MODULE_NAME}-${{ steps.version.outputs.version }}.tar.gz" > SHA256SUMS
- name: Create Release
uses: softprops/action-gh-release@v2
with:
generate_release_notes: true
files: |
*.tar.gz
SHA256SUMS