Skip to content

Commit

Permalink
Updates
Browse files Browse the repository at this point in the history
Added .github workflows
  • Loading branch information
ondrovic committed Oct 3, 2024
1 parent 4bff81c commit 67cd2e4
Show file tree
Hide file tree
Showing 4 changed files with 216 additions and 0 deletions.
27 changes: 27 additions & 0 deletions .github/scripts/generate_config.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/bash

ISSUE_TEMPLATE_CREATED_FILE=".github/ISSUE_TEMPLATE/issue_template_configured.txt"

# Check if the repository name is provided
if [ -z "$1" ]; then
echo "Usage: $0 <repository-name>"
exit 1
fi

# Check if the script has already run
if [ -f "$FLAG_FILE" ]; then
echo "Config has already been generated."
exit 0
fi

REPO=$1
TEMPLATE_FILE=".github/ISSUE_TEMPLATE/config.template.yml"
OUTPUT_FILE=".github/ISSUE_TEMPLATE/config.yml"

# Replace placeholder with actual repository name
sed "s/{REPO}/$REPO/g" $TEMPLATE_FILE > $OUTPUT_FILE

# Create a file with a timestamp to indicate the script has run
echo "Config generated for repository: $REPO on $(date '+%Y-%m-%d %H:%M:%S')" > "$ISSUE_TEMPLATE_CREATED_FILE"

echo "Generated config.yml for repository: $REPO"
37 changes: 37 additions & 0 deletions .github/workflows/releaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# .github/workflows/release.yml
name: releaser

on:
push:
tags:
- "*"

permissions:
contents: write
# packages: write
issues: write

jobs:
goreleaser:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: stable
# More assembly might be required: Docker logins, GPG, etc.
# It all depends on your needs.
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v6
with:
# either 'goreleaser' (default) or 'goreleaser-pro'
distribution: goreleaser
# 'latest', 'nightly', or a semver
version: "~> v2"
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
66 changes: 66 additions & 0 deletions .github/workflows/testing.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: testing

on:
push:
branches:
- "**" # Match all branches
tags-ignore:
- "*" # Ignore all tags
pull_request:
branches:
- "**" # Match all branches

jobs:
testing:
runs-on: ubuntu-latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: stable

- name: Install dependencies
run: go mod download

- name: Run tests
run: go test -coverprofile=unit.coverage.out ./...
# Uncomment for uploading when setup
# - name: Upload results to Codecov
# uses: codecov/codecov-action@v4
# with:
# files: ./unit.coverage.out
# fail_ci_if_error: false
# flags: unittests
# name: codecov-umbrella
# token: ${{ secrets.CODECOV_TOKEN }}
# verbose: true

# - name: Upload coverage report
# uses: actions/upload-artifact@v2
# with:
# name: coverage-report
# path: unit.coverage.out

# codacy-coverage-reporter:
# needs: testing
# runs-on: ubuntu-latest
# name: codacy-coverage-reporter
# steps:
# - uses: actions/checkout@v2
# - name: Download coverage report
# uses: actions/download-artifact@v2
# with:
# name: coverage-report
# - name: Run codacy-coverage-reporter
# uses: codacy/codacy-coverage-reporter-action@v1.3.0
# with:
# project-token: ${{ secrets.CODACY_PROJECT_TOKEN }}
# coverage-reports: unit.coverage.out
# force-coverage-parser: go

86 changes: 86 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
version: 2

project_name: file-finder

env:
- GO_MAIN_PATH=app/cmd/finder/file-finder.go


before:
hooks:
# Tidy
- go mod tidy
# Generate
- go generate ./...

builds:
- id: windows
main: '{{ .Env.GO_MAIN_PATH }}'
env:
- CGO_ENABLED=0
goos:
- windows
goarch:
- amd64
ldflags:
- -s -w
- -X go.szostok.io/version.version={{.Version}}
- -X go.szostok.io/version.buildDate={{.Date}}
- -X go.szostok.io/version.commit={{.FullCommit}}
- -X go.szostok.io/version.commitDate={{.CommitDate}}
- -X go.szostok.io/version.dirtyBuild={{.IsGitDirty}}

- id: linux
main: '{{ .Env.GO_MAIN_PATH }}'
env:
- CGO_ENABLED=0
goos:
- linux
goarch:
- amd64
ldflags:
- -s -w
- -X go.szostok.io/version.version={{.Version}}
- -X go.szostok.io/version.buildDate={{.Date}}
- -X go.szostok.io/version.commit={{.FullCommit}}
- -X go.szostok.io/version.commitDate={{.CommitDate}}
- -X go.szostok.io/version.dirtyBuild={{.IsGitDirty}}

- id: macos
main: '{{ .Env.GO_MAIN_PATH }}'
env:
- CGO_ENABLED=0
goos:
- darwin
goarch:
- amd64
ldflags:
- -s -w
- -X go.szostok.io/version.version={{.Version}}
- -X go.szostok.io/version.buildDate={{.Date}}
- -X go.szostok.io/version.commit={{.FullCommit}}
- -X go.szostok.io/version.commitDate={{.CommitDate}}
- -X go.szostok.io/version.dirtyBuild={{.IsGitDirty}}

archives:
- format: tar.gz
# this name template makes the OS and Arch compatible with the results of `uname`.
name_template: >-
{{ .ProjectName }}_
{{- if eq .Os "darwin" }}MacOs
{{- else }}{{ title .Os }}{{ end }}_
{{- if eq .Arch "amd64" }}x86_64{{ else }}{{ .Arch }}{{ end }}
# use zip for windows archives
format_overrides:
- goos: windows
format: zip

checksum:
name_template: "checksums.txt"

changelog:
sort: asc
filters:
exclude:
- "^docs:"
- "^test:"

0 comments on commit 67cd2e4

Please sign in to comment.