Skip to content

fix release yaml

fix release yaml #2

Workflow file for this run

name: Release
on:
push:
branches:
- main
tags:
- 'v*'
workflow_dispatch:
inputs:
version:
description: 'Release version tag (e.g. v1.0.0, leave empty for timestamp tag)'
required: false
default: ''
permissions:
contents: write
jobs:
test:
name: Run Tests & Verification
runs-on: ubuntu-latest
steps:
- name: Checkout Source
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
cache: true
- name: Run Linters
run: make lint
- name: Run Tests
run: make test
build-and-release:
name: Build & Release
needs: test
runs-on: ubuntu-latest
steps:
- name: Checkout Source (full history)
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
cache: true
- name: Determine Release Tag & Time
id: release_info
run: |
export TZ=Asia/Kolkata
DISPLAY_TIME=$(date +'%d %b %Y, %H:%M IST')
echo "DISPLAY_TIME=$DISPLAY_TIME" >> $GITHUB_OUTPUT
if [ "${{ github.event_name }}" = "workflow_dispatch" ] && [ -n "${{ github.event.inputs.version }}" ]; then
TAG="${{ github.event.inputs.version }}"
elif [ "${{ github.ref_type }}" = "tag" ]; then
TAG="${{ github.ref_name }}"
else
TAG=$(date +'%Y_%m_%d_%H_%M_%S')
fi
echo "TAG=$TAG" >> $GITHUB_OUTPUT
- name: Build Binaries with Makefile
run: make build VERSION=${{ steps.release_info.outputs.TAG }}
- name: Generate SHA256 Checksums
run: |
cd builds
sha256sum DrivePulse-windows-x64.exe DrivePulse-linux-x64 > checksums.txt
cat checksums.txt
- name: Generate Changelog
id: changelog
run: |
LAST_TAG=$(git describe --tags --exclude='latest' --abbrev=0 HEAD~1 2>/dev/null || echo "")
if [ -z "$LAST_TAG" ]; then
LOG=$(git log --pretty=format:"- %s ([%h](https://github.com/${{ github.repository }}/commit/%H))")
else
LOG=$(git log ${LAST_TAG}..HEAD --pretty=format:"- %s ([%h](https://github.com/${{ github.repository }}/commit/%H))")
fi
{
echo "CHANGELOG<<EOF"
echo "### 🚀 Changes"
echo ""
echo "$LOG"
echo ""
echo "EOF"
} >> "$GITHUB_OUTPUT"
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.release_info.outputs.TAG }}
name: "DrivePulse Release #${{ github.run_number }} (${{ steps.release_info.outputs.TAG }})"
body: |
⚡ **DrivePulse Automated Release**
📅 **Built at:** ${{ steps.release_info.outputs.DISPLAY_TIME }}
${{ steps.changelog.outputs.CHANGELOG }}
### 📦 Artifacts & Integrity
Binary assets are attached below along with `checksums.txt` (SHA256).
files: |
builds/DrivePulse-windows-x64.exe
builds/DrivePulse-linux-x64
builds/checksums.txt
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Update latest tag
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git tag -fa latest -m "Update latest tag to ${{ steps.release_info.outputs.TAG }}"
git push origin latest --force