Skip to content

Auto Tagging And Release After Tests #5

Auto Tagging And Release After Tests

Auto Tagging And Release After Tests #5

Workflow file for this run

name: Manual Tagging After Tests
on:
push:
tags:
- "v*" # The pattern here matches the tag naming convention you will use
workflow_dispatch:
inputs:
tag_name:
description: "Tag name"
required: true
default: "v0.0.1"
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.22.5
- name: Run tests
run: |
go test -v ./...
untagging:
needs: [ test ]
if: failure()
runs-on: ubuntu-latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Use your PAT here instead of the default token
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
ref: ${{ github.ref }}
- name: Untag release
run: |
git config --global user.email "[email protected]"
git config --global user.name "Github Actions"
git tag -d ${{ github.ref_name }} # Delete local tag
git push origin :refs/tags/${{ github.ref_name }} # Delete remote tag
tagging:
needs: [ test ]
if: success()
runs-on: ubuntu-latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Use your PAT here instead of the default token
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
ref: ${{ github.ref }}
- name: Tag release
run: |
git config --global user.email "[email protected]"
git config --global user.name "Github Actions"
git tag ${{ github.event.inputs.tag_name }}
git push origin ${{ github.event.inputs.tag_name }}