From 493c84f402504aa58f46ccca4f2d63ad546b4cb3 Mon Sep 17 00:00:00 2001 From: GirishCodeAlchemy Date: Sat, 27 Jan 2024 11:10:18 -0500 Subject: [PATCH 1/3] Fix the directory flag to override the command line and enhance githu action to create release --- .github/workflows/go.yml | 24 +++++++++++++++++++++--- build.sh | 5 ++++- main.go | 2 +- 3 files changed, 26 insertions(+), 5 deletions(-) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index fa564cb..906142f 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -1,6 +1,3 @@ -# This workflow will build a golang project -# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go - name: TopNDiskAnalyzer on: @@ -27,3 +24,24 @@ jobs: - name: Package run: ./build.sh + - name: Create Release + id: create_release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ github.ref }} + release_name: Release ${{ github.ref }} + draft: false + prerelease: false + + - name: Upload Release Asset + id: upload-release-asset + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: ./package + asset_name: package + asset_content_type: application/octet-stream diff --git a/build.sh b/build.sh index b994565..b380c09 100755 --- a/build.sh +++ b/build.sh @@ -2,6 +2,9 @@ platforms=("linux/amd64" "linux/386" "darwin/amd64" "windows/amd64" "windows/386") +# Create a package folder if it doesn't exist +mkdir -p package + for platform in "${platforms[@]}" do platform_split=(${platform//\// }) @@ -13,5 +16,5 @@ do output_name="tdf.exe" fi - env GOOS=$GOOS GOARCH=$GOARCH go build -o $output_name main.go + env GOOS=$GOOS GOARCH=$GOARCH go build -o package/$output_name main.go done diff --git a/main.go b/main.go index c733df3..6e069e3 100644 --- a/main.go +++ b/main.go @@ -34,7 +34,7 @@ func main() { var topN int var showHelp bool - flag.StringVar(&dirPath, "dir", ".", "Directory path") + flag.StringVar(&dirPath, "dir", "", "Directory path") flag.IntVar(&topN, "top", 10, "Number of top items to display") flag.BoolVar(&showHelp, "help", false, "Show help message") flag.Parse() From 7a6244ac1e3949e2afe959b51a597061d3a03049 Mon Sep 17 00:00:00 2001 From: GirishCodeAlchemy Date: Sat, 27 Jan 2024 11:15:55 -0500 Subject: [PATCH 2/3] Fix the githubaction build --- .github/workflows/go.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 906142f..4e68631 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -30,8 +30,8 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: - tag_name: ${{ github.ref }} - release_name: Release ${{ github.ref }} + tag_name: v${{ github.run_number }} + release_name: Release ${{ github.run_number }} draft: false prerelease: false From f17816b5fb0a575b7e50c9af71bc50712ca176c0 Mon Sep 17 00:00:00 2001 From: GirishCodeAlchemy Date: Sat, 27 Jan 2024 11:36:51 -0500 Subject: [PATCH 3/3] Fix the githubaction build --- .github/workflows/go.yml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 4e68631..3b2a086 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -30,8 +30,10 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: - tag_name: v${{ github.run_number }} - release_name: Release ${{ github.run_number }} + # tag_name: v${{ github.run_number }} + # release_name: Release ${{ github.run_number }} + tag_name: ${{ github.ref }} + release_name: Release ${{ github.ref }} draft: false prerelease: false @@ -42,6 +44,6 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_path: ./package + asset_path: ./package/** asset_name: package - asset_content_type: application/octet-stream + asset_content_type: application/octet-stream \ No newline at end of file