diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index fa564cb..3b2a086 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,26 @@ 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: v${{ github.run_number }} + # release_name: Release ${{ github.run_number }} + 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 \ No newline at end of file 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()