Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathanagustin committed Nov 21, 2024
1 parent d6acedb commit d44cd83
Show file tree
Hide file tree
Showing 7 changed files with 1,920 additions and 69 deletions.
61 changes: 61 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: Continuous Integration

on:
push:
branches:
- develop
- feature/**
- release/**
pull_request:
branches:
- develop
- release/**

jobs:
build-test:
runs-on: ubuntu-latest
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
go-version: ['1.23']
steps:
- name: Checkout Code
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2

- name: Set up Go
uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5.1.0
with:
go-version: ${{ matrix.go-version }}

- name: Cache Go Modules
uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4.1.2
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Install Dependencies
run: |
task deps
- name: Run Linters
run: |
task lint
- name: Run Tests
run: |
task test
- name: Build Application
run: |
task build
- name: Upload Build Artifacts
if: success()
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
with:
name: build-${{ matrix.os }}
path: build/
180 changes: 180 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,180 @@
name: Release

on:
push:
tags:
- 'v*.*.*'

jobs:
release:
runs-on: ubuntu-latest
env:
VERSION: ${{ github.ref_name }}
steps:
- name: Checkout Code
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2

- name: Set up Go
uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5.1.0
with:
go-version: '1.23'

- name: Install Dependencies
run: |
task deps
- name: Run Tests
run: |
task test
- name: Build for Windows
env:
GOOS: windows
GOARCH: amd64
run: |
task build
shell: bash

- name: Build for Linux
env:
GOOS: linux
GOARCH: amd64
run: |
task build
shell: bash

- name: Build for macOS
env:
GOOS: darwin
GOARCH: amd64
run: |
task build
shell: bash

- name: Package Binaries
run: |
mkdir -p package/${VERSION}
# Package Windows
cd build
zip -r ../package/${VERSION}/omnivex-${VERSION}-windows-amd64.zip omnivex.exe
cd ..
# Package Linux
tar -czvf package/${VERSION}/omnivex-${VERSION}-linux-amd64.tar.gz -C build omnivex
# Package macOS
tar -czvf package/${VERSION}/omnivex-${VERSION}-darwin-amd64.tar.gz -C build omnivex
# Generate Checksums
cd package/${VERSION}
sha256sum * > checksums.txt
cd ../../
- name: Generate Release Notes
id: releasenotes
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
with:
script: |
const { owner, repo } = context.repo;
const tag = context.ref.replace('refs/tags/', '');
const latestRelease = await github.rest.repos.getLatestRelease({
owner,
repo,
}).catch(() => null);
const since = latestRelease ? latestRelease.data.published_at : '1970-01-01T00:00:00Z';
const pullRequests = await github.rest.pulls.list({
owner,
repo,
state: 'closed',
sort: 'updated',
direction: 'desc',
per_page: 100,
});
const mergedPRs = pullRequests.data.filter(pr => pr.merged_at && new Date(pr.merged_at) > new Date(since));
let releaseNotes = `## Release ${tag}\n\n### Changes\n\n`;
if (mergedPRs.length === 0) {
releaseNotes += '- No changes\n';
} else {
const categories = {
'🚀 Features': [],
'🐛 Bug Fixes': [],
'🛠 Maintenance': [],
'Other': []
};
mergedPRs.forEach(pr => {
const labels = pr.labels.map(label => label.name);
if (labels.includes('feature')) {
categories['🚀 Features'].push(pr);
} else if (labels.includes('bug')) {
categories['🐛 Bug Fixes'].push(pr);
} else if (labels.includes('chore') || labels.includes('refactor')) {
categories['🛠 Maintenance'].push(pr);
} else {
categories['Other'].push(pr);
}
});
for (const [category, prs] of Object.entries(categories)) {
if (prs.length > 0) {
releaseNotes += `### ${category}\n\n`;
prs.forEach(pr => {
releaseNotes += `- ${pr.title} @${pr.user.login} (#${pr.number})\n`;
});
releaseNotes += `\n`;
}
}
}
return releaseNotes;
result-encoding: string

- name: Create GitHub Release
id: create_release
uses: actions/create-release@0cb9c9b65d5d1901c1f53e5e66eaf4afd303e70e # v1.1.4
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
body: ${{ steps.releasenotes.outputs.result }}
draft: false
prerelease: ${{ startsWith(github.ref_name, 'v') && contains(github.ref_name, '-') }}

- name: Upload Release Assets (Windows)
uses: actions/upload-release-asset@e8f9f06c4b078e705bd2ea027f0926603fc9b4d5 # v1.0.2
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./package/${{ env.VERSION }}/omnivex-${{ env.VERSION }}-windows-amd64.zip
asset_name: omnivex-${{ env.VERSION }}-windows-amd64.zip
asset_content_type: application/zip

- name: Upload Release Assets (Linux)
uses: actions/upload-release-asset@e8f9f06c4b078e705bd2ea027f0926603fc9b4d5 # v1.0.2
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./package/${{ env.VERSION }}/omnivex-${{ env.VERSION }}-linux-amd64.tar.gz
asset_name: omnivex-${{ env.VERSION }}-linux-amd64.tar.gz
asset_content_type: application/gzip

- name: Upload Release Assets (macOS)
uses: actions/upload-release-asset@e8f9f06c4b078e705bd2ea027f0926603fc9b4d5 # v1.0.2
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./package/${{ env.VERSION }}/omnivex-${{ env.VERSION }}-darwin-amd64.tar.gz
asset_name: omnivex-${{ env.VERSION }}-darwin-amd64.tar.gz
asset_content_type: application/gzip

- name: Upload Checksums
uses: actions/upload-release-asset@e8f9f06c4b078e705bd2ea027f0926603fc9b4d5 # v1.0.2
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./package/${{ env.VERSION }}/checksums.txt
asset_name: checksums.txt
asset_content_type: text/plain
23 changes: 20 additions & 3 deletions Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -171,9 +171,8 @@ tasks:

deps:install-tools:
desc: Install development tools
cmds:
- echo "🔧 Installing development tools..."
- task: install-tools
deps: [install-tools:godoc, install-tools:golangci-lint, install-tools:check-curl]
cmds: []

install-tools:
desc: Install development tools
Expand All @@ -183,8 +182,26 @@ tasks:
install-tools:golangci-lint:
desc: Install 'golangci-lint'
cmds:
- echo "🔧 Installing 'golangci-lint'..."
- go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest

install-tools:godoc:
desc: Install 'godoc' tool
cmds:
- echo "🔧 Installing 'godoc'..."
- go install golang.org/x/tools/cmd/godoc@latest

install-tools:check-curl:
desc: Ensure 'curl' is installed
cmds:
- |
if ! command -v curl >/dev/null 2>&1; then
echo "❌ 'curl' is not installed. Please install it using your package manager."
exit 1
else
echo "✅ 'curl' is installed."
fi
update-deps:
desc: Update project dependencies
prompt: This will update all dependencies. Continue?
Expand Down
Loading

0 comments on commit d44cd83

Please sign in to comment.