Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Release Terraform Modules | |
on: | |
push: | |
tags: | |
- 'v*.*.*' | |
jobs: | |
release: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- id: create-version | |
uses: paulhatch/[email protected] | |
with: | |
# The prefix to use to identify tags | |
tag_prefix: "v" | |
# A string which, if present in a git commit, indicates that a change represents a | |
# major (breaking) change, supports regular expressions wrapped with '/' | |
major_pattern: "(MAJOR)" | |
# Same as above except indicating a minor change, supports regular expressions wrapped with '/' | |
minor_pattern: "(MINOR)" | |
# A string to determine the format of the version output | |
version_format: "${major}.${minor}.${patch}" | |
# Prevents pre-v1.0.0 version from automatically incrementing the major version. | |
# If enabled, when the major version is 0, major releases will be treated as minor and minor as patch. Note that the version_type output is unchanged. | |
enable_prerelease_mode: true | |
# If enabled, diagnostic information will be added to the action output. | |
debug: false | |
# If true, the branch will be used to select the maximum version. | |
version_from_branch: false | |
- name: Set up Terraform | |
uses: hashicorp/setup-terraform@v1 | |
- name: Validate Terraform | |
run: | | |
cd test | |
terraform init | |
terraform validate | |
cd .. | |
- name: Package Terraform modules | |
env: | |
VERSION: ${{ steps.create-version.outputs.version }} | |
run: | | |
mkdir -p release | |
cd release | |
export RELEASES=$(pwd) | |
for dir in modules/* | |
do | |
pushd $dir | |
zip -r ${RELEASES}/$(basename $dir).zip . | |
popd | |
done | |
- name: Create release and upload assets | |
run: | | |
set -x | |
assets=() | |
for asset in ./release/*.zip; do | |
assets+=("$asset") | |
done | |
gh release create -t "Release ${VERSION}" ${VERSION} | |
gh release upload ${VERSION} ${assets[@]} | |
env: | |
VERSION: ${{ steps.create-version.outputs.version }} | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |