Skip to content

Create Draft Release #9

Create Draft Release

Create Draft Release #9

name: Create Draft Release
on:
workflow_dispatch:
inputs:
version:
description: Tag name for the release.
required: true
jobs:
create_draft_release:
name: Create Draft Release
runs-on: ubuntu-latest
outputs:
upload_url: ${{ steps.create_release.outputs.upload_url }}
steps:
- name: Create release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.event.inputs.version }}
release_name: Release v${{ github.event.inputs.version }}
draft: true
build_release_binary:
needs: create_draft_release
name: Build Release Binary
strategy:
matrix:
include:
- runner: ubuntu-latest
os: linux
- runner: windows-latest
os: windows
- runner: macos-latest
os: macos
runs-on: ${{ matrix.runner }}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: 3.11
- name: Install plugin framework and example plugins
run: |
pip install ./plugins ./example/plugin-example
- uses: hashicorp/setup-terraform@v2
with:
terraform_wrapper: false
- name: Install Go toolchain
uses: actions/setup-go@v4
with:
go-version-file: "src/go.mod"
cache-dependency-path: "src/go.sum"
- name: Generate Binary Name
id: binary_name
shell: bash
run: |
binary_name="infra-tester"
release_binary_name="infra-tester-${{ matrix.os }}-x86_64"
if [[ ${{ matrix.os }} == "windows" ]]; then
binary_name="${binary_name}.exe"
release_binary_name="${release_binary_name}.exe"
fi
echo "binary_name=$binary_name" >> "$GITHUB_OUTPUT"
echo "release_binary_name=$release_binary_name" >> "$GITHUB_OUTPUT"
- name: Compile Test Binary
run: |
cd src/
go test -c -o ../bin/${{ steps.binary_name.outputs.binary_name }}
- name: Run Example Terraform Tests
run: |
cd example
../bin/${{ steps.binary_name.outputs.binary_name }} "-test.v"
- name: Upload Release Asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.create_draft_release.outputs.upload_url }}
asset_path: ./bin/${{ steps.binary_name.outputs.binary_name }}
asset_name: ${{ steps.binary_name.outputs.release_binary_name }}
asset_content_type: application/octet-stream