Skip to content

Instantly share code, notes, and snippets.

@manwar
Created March 22, 2025 01:22
Show Gist options
  • Save manwar/6dea0096e32d8937d4d71afcef1399f0 to your computer and use it in GitHub Desktop.
Save manwar/6dea0096e32d8937d4d71afcef1399f0 to your computer and use it in GitHub Desktop.
Workflow Setup

First we need Personal Access Token (PAT) with workflow permission.

My existing PAT didn't have the permisson to create/update workflows.

So I created a new PAT.

Step 1: Go to your GitHub account settings.
Step 2: Navigate to Developer settings 
Step 3: Personal access tokens 
Step 4: Generate new token.
Step 5: Select the repo scope including workflow

Copy the PAT and save it securely.

Now open a terminal and check the credential helper.

$ git config --global credential.helper

If it is stores then edit the ~/.git-credentials file and add the new PAT.

You should then be able to push the changes with the workflow file.

One last thing, you will need to do is, add the PAT to Repository Secrets:

Step 1: Go to your repository settings.
Step 2: Navigate to Secrets and variables
Step 3: Actions.

Click New repository secret.

Then name the secret WORKFLOW_PAT and paste the new PAT.

Finally push a new tag, it should create a new release.

The workflow file looks like below:

name: Release on Tag

on:
  push:
    tags:
      - 'v*'

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
    - name: Checkout code
      uses: actions/checkout@v3

  release:
    needs: build
    runs-on: ubuntu-latest

    steps:
    - name: Checkout code
      uses: actions/checkout@v3

    - name: Create Release
      id: create_release
      uses: actions/create-release@v1
      env:
        GITHUB_TOKEN: ${{ secrets.WORKFLOW_PAT }}
      with:
        tag_name: ${{ github.ref }}
        release_name: Release ${{ github.ref }}
        draft: false
        prerelease: false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment