Skip to content

Updates for Times on Dates #44

Updates for Times on Dates

Updates for Times on Dates #44

Workflow file for this run

name: Build and Release
on:
push:
branches:
- main
- dev
jobs:
build:
name: Build and Release Artifacts
runs-on: ubuntu-latest
permissions:
contents: write # Required for creating releases
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: 1.21
- name: Set Version
id: version
run: |
if [ "${{ github.ref }}" = "refs/heads/main" ]; then
echo "version=$(cat VERSION)" >> $GITHUB_ENV
else
echo "version=dev" >> $GITHUB_ENV
fi
- name: Print Version
run: echo "Building version ${{ env.version }}"
- name: Build Linux Binary
run: |
GOOS=linux GOARCH=amd64 go build -ldflags="-w -s -X main.version=${{ env.version }}" -o isley-linux
- name: Build Windows Binary
run: |
GOOS=windows GOARCH=amd64 go build -ldflags="-w -s -X main.version=${{ env.version }}" -o isley.exe
- name: Build Docker Image
run: |
docker build -t isley:${{ env.version }} .
- name: Push Docker Image (Main Branch Only)
if: github.ref == 'refs/heads/main'
run: |
echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u "${{ secrets.DOCKER_USERNAME }}" --password-stdin
docker tag isley:${{ env.version }} dwot/isley:${{ env.version }}
docker tag isley:${{ env.version }} dwot/isley:latest
docker push dwot/isley:${{ env.version }}
docker push dwot/isley:latest
- name: Generate Release Notes
id: release_notes
run: |
# Get the current date
release_date=$(date -u +"%Y-%m-%d")
echo "Release Date: $release_date" > release_notes.md
# Determine the commit range
if git describe --tags --abbrev=0 > /dev/null 2>&1; then
# If tags exist, get commits since the last tag
commit_range="$(git describe --tags --abbrev=0 @^)..@"
else
# If no tags exist, get all commits
commit_range="HEAD"
fi
# Add commit messages
echo -e "\n### Commits:\n" >> release_notes.md
git log --pretty=format:"- %s (%h)" $commit_range >> release_notes.md
# Escape multiline release notes for GITHUB_ENV
escaped_notes=$(awk '{printf "%s\\n", $0}' release_notes.md)
echo "release_notes=${escaped_notes}" >> $GITHUB_ENV
- name: Release Artifacts (Main Branch Only)
if: github.ref == 'refs/heads/main'
uses: softprops/action-gh-release@de2c0eb89ae2a093876385947365aca7b0e5f844
with:
tag_name: v${{ env.version }}
name: Release v${{ env.version }}
body: ${{ env.release_notes }}
files: |
isley-linux
isley.exe
- name: Cleanup Release Notes
run: rm -f release_notes.md