Skip to content

Commit

Permalink
Update: added github action + version bumping script and goreleaser c…
Browse files Browse the repository at this point in the history
…onfig

Signed-off-by: deggja <danieldagfinrud@gmail.com>
  • Loading branch information
deggja committed Nov 22, 2023
1 parent b920c55 commit 0365a3e
Show file tree
Hide file tree
Showing 3 changed files with 96 additions and 0 deletions.
31 changes: 31 additions & 0 deletions .github/bump_version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/bash

# Fetch tags
git fetch --tags

# Get the latest tag
latest_tag=$(git describe --tags `git rev-list --tags --max-count=1`)

# If there are no tags yet, start with 0.0.1
if [ -z "$latest_tag" ]; then
new_tag="0.0.1"
else
# Increment the version
major=$(echo $latest_tag | cut -d. -f1)
minor=$(echo $latest_tag | cut -d. -f2)
patch=$(echo $latest_tag | cut -d. -f3)
if [ $patch -lt 99 ]; then
let patch+=1
else
let minor+=1
patch=0
fi
new_tag="${major}.${minor}.${patch}"
fi

# Set output for the next steps
echo "Setting new tag to $new_tag"
echo "::set-output name=new_tag::$new_tag"

# Create the new tag
git tag $new_tag
33 changes: 33 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Release

on:
push:
branches:
- main

jobs:
build-and-release:
name: Build and Release
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v2

- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.15

- name: Bump version and tag
id: bump_version
run: |
chmod +x .github/scripts/bump_version.sh
.github/scripts/bump_version.sh
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2
with:
version: latest
args: release --rm-dist --tag ${{ steps.bump_version.outputs.new_tag }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
32 changes: 32 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# .goreleaser.yml
project_name: netfetch # Replace with your project name

# Build configuration
builds:
- id: "netfetch"
main: ./cmd/netfetch/main.go # Path to your main.go file
binary: netfetch
goos:
- linux
- darwin
- windows
goarch:
- amd64
- arm64
# Additional build flags can be added here

# Archive configuration
archives:
- id: "archive"
builds:
- netfetch
format: tar.gz
name_template: "{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}"
wrap_in_directory: true

# Release configuration
release:
github:
owner: deggja
name: netfetch
draft: false

0 comments on commit 0365a3e

Please sign in to comment.