Skip to content

Commit

Permalink
Merge pull request #351 from warrensbox/fix/refactor-deployment
Browse files Browse the repository at this point in the history
Fix/refactor deployment
  • Loading branch information
warrensbox authored Apr 2, 2024
2 parents 6aaa2c4 + 185f572 commit c9f4cd8
Showing 1 changed file with 55 additions and 19 deletions.
74 changes: 55 additions & 19 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,26 +1,32 @@
# Trigger when MR to `release` is closed

name: Build-Test-Release Code
name: Release (Manual Step)

on:
pull_request:
types:
- closed
branches:
- release

workflow_dispatch:
inputs:
name:
description: "Enter - major, minor, patch"
default: "patch"

jobs:
tfswitch-release:
name: Release
runs-on: ubuntu-20.04
steps:

- name: Check if provided input is valid
run: |
echo "Semantic Version: ${{ github.event.inputs.name }}"
VERSION=${{ github.event.inputs.name }}
if [ "$VERSION" != "major" ] && [ "$VERSION" != "minor" ] && [ "$VERSION" != "patch" ]; then
echo "Error: Provided input string must be 'major', 'minor', or 'patch'"
exit 1
fi
# Checkout code from repo
- uses: actions/checkout@v4
with:
ref: ${{ github.ref_name }} # required for better experience using pre-releases
#fetch-depth: '0'
ref: ${{ github.head_ref }} # required for better experience using pre-releases
fetch-depth: '0'

# Install go
- name: Checkout go
Expand All @@ -42,21 +48,51 @@ jobs:
run: mkdir -p build && go build -v -o build/tfswitch && build/tfswitch --help
continue-on-error: false

# Introduce new tag
- name: Create dry tag
uses: anothrNick/github-tag-action@1.67.0
id: semver-tag-dry
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
WITH_V: false
INITIAL_VERSION: 1.0.0
RELEASE_BRANCHES: master
DEFAULT_BUMP: ${{ github.event.inputs.name }}
PRERELEASE: false
DRY_RUN: true #only get the tag - dry
VERBOSE: true

# Write new version into version file
- name: Write new version tag to version file
run: |
echo ${{ steps.semver-tag-dry.outputs.tag }} > version
# Commit the changes in the previous step
- name: Commit version into repo
run: |
git config --global user.email "release-bot@users.noreply.github.com"
git config --global user.name "release-bot"
git commit -a -m "#{{ github.event.inputs.name }} - Setting semantic version"
# Push the changes to remote
- name: Push changes
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: ${{ github.ref }}

# Introduce new tag (for real)
- name: Bump version and push tag
uses: anothrNick/github-tag-action@1.67.0
id: tagging
id: semver-tag
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
WITH_V: false
INITIAL_VERSION: 1.0.0
RELEASE_BRANCHES: release
DEFAULT_BUMP: patch
RELEASE_BRANCHES: master
DEFAULT_BUMP: ${{ github.event.inputs.name }}
PRERELEASE: false
DRY_RUN: false
DRY_RUN: false #not dry
VERBOSE: true
BRANCH_HISTORY: last
TAG_CONTEXT: branch

# Run goreleaser to create new binaries
- name: Run GoReleaser
Expand All @@ -66,7 +102,7 @@ jobs:
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
RELEASE_VERSION: ${{ steps.tagging.outputs.tag }}
RELEASE_VERSION: ${{ steps.semver-tag.outputs.tag }}
PERSONAL_ACCESS_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}

- name: Install Python
Expand Down

0 comments on commit c9f4cd8

Please sign in to comment.