Skip to content

Release (Manual)

Release (Manual) #32

Workflow file for this run

name: Release (Manual)
on:
workflow_dispatch:
inputs:
name:
description: "Semver - major, minor, patch"
default: "patch"
jobs:
semver:
runs-on: ubuntu-latest
steps:
- name: Check input
run: |
echo "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
- uses: actions/checkout@v3
with:
ref: ${{ github.head_ref }} # required for better experience using pre-releases
fetch-depth: '0'
- name: Checkout go
uses: actions/setup-go@v4
with:
go-version: '1.22' # The Go version to download (if necessary) and use.
- name: Go version
id: Version
run: go version
- name: Go download
run: go mod download
- name: Go test
run: go test -v ./...
continue-on-error: false
- name: Create dry run 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
VERBOSE: true
- name: Commit new version tag to version file
run: |
echo ${{ steps.semver-tag-dry.outputs.tag }} > version
- name: Create release
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"
- name: Push changes
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: ${{ github.ref }}
# Push the changes to remote
- name: Push changes
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: release-${{ steps.semver-tag-dry.outputs.tag }}
- name: Create Pull Request
id: cpr
uses: peter-evans/create-pull-request@v6
with:
token: ${{ secrets.GITHUB_TOKEN }}
branch: release-${{ steps.semver-tag-dry.outputs.tag }}
title: Release ${{ steps.semver-tag-dry.outputs.tag }}
labels: automerge
- name: Merging release PR
run: gh pr merge --merge --auto "${{ steps.cpr.outputs.pull-request-number }}"
env:
GH_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
- name: Create dry run tag
uses: anothrNick/github-tag-action@1.67.0
id: semver-tag #test4
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: false
VERBOSE: true
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v5
with:
version: latest
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
RELEASE_VERSION: ${{ steps.semver-tag.outputs.tag }}
CLIENT_ID: ${{ secrets.CLIENT_ID }}
CLIENT_SECRET: ${{ secrets.CLIENT_SECRET }}
PERSONAL_ACCESS_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}