update readme #69
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: Go build and push container | |
on: | |
push: | |
branches: [ "main" ] | |
# paths: | |
# - "*.go" | |
# - "*/*.go" | |
# - "*/*/*.go" | |
defaults: | |
run: | |
working-directory: ./ | |
env: | |
IS_CHANGED: false | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up Go | |
uses: actions/setup-go@v3 | |
with: | |
go-version: 1.19.3 | |
- name: Clean mod file | |
run: go mod tidy | |
- name: Build for tests | |
run: go build -v -ldflags="-X 'github.com/sirrend/terrap-cli/internal/version.Version=${GITHUB_SHA::6}'" | |
- uses: actions/upload-artifact@master | |
with: | |
name: terrap | |
path: ./tests | |
tests: | |
runs-on: ubuntu-latest | |
needs: build | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/download-artifact@master | |
with: | |
name: terrap | |
path: ./tests | |
- name: Change permissions | |
run: chmod u+x terrap | |
- name: Test | |
run: sudo ./terrap init -d ./terraform-test | |
release: | |
runs-on: ubuntu-latest | |
needs: tests | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/download-artifact@master | |
with: | |
name: terrap | |
path: ./ | |
- name: Change permissions | |
run: chmod u+x terrap | |
- name: Get Current Version | |
run: echo "current_version=$(grep '# version' version.md | cut -d ' ' -f3)" >> $GITHUB_ENV | |
id: current_version | |
- name: FragileTech/bump-version | |
uses: FragileTech/bump-version@main | |
with: | |
current_version: "${{ env.current_version }}" | |
files: ./version.md | |
commit_name: sirrend-terrap | |
commit_email: business@sirrend.com | |
login: ${{ secrets.ACTION_USERNAME }} | |
token: ${{ github.token }} | |
- name: Get New Version | |
run: echo "new_version=$(grep '# version' version.md | cut -d ' ' -f3)" >> $GITHUB_ENV | |
id: new_version | |
- name: Final build | |
env: | |
GOTRACEBACK: "none" | |
run: go build -v -ldflags="-X 'github.com/sirrend/terrap-cli/internal/version.Version=${{ env.new_version }}'" | |
- name: Release | |
uses: actions/create-release@v1 | |
id: create_release | |
with: | |
draft: false | |
prerelease: false | |
release_name: v${{ env.new_version }} | |
tag_name: v${{ env.new_version }} | |
body_path: ./CHANGELOG.md | |
env: | |
GITHUB_TOKEN: ${{ github.token }} | |
- name: upload artifacts | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ github.token }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: ./terrap | |
asset_name: terrap | |
asset_content_type: octet-stream |