From a091d78cf1fdf699baeaf499ec2cf8c9ed46cf2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bal=C3=A1zs=20Grill?= Date: Wed, 21 Aug 2024 19:17:49 +0200 Subject: [PATCH] Release in CI --- .github/workflows/go.yml | 39 ++++++++++++++++++++++++++++++++++++++- cmd/main/main.go | 3 +++ 2 files changed, 41 insertions(+), 1 deletion(-) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index e35a774..af8ea60 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -6,6 +6,8 @@ name: Go on: push: branches: [ "main" ] + tags: + - '*' pull_request: branches: [ "main" ] @@ -16,6 +18,21 @@ jobs: steps: - uses: actions/checkout@v4 + - id: get_version + if: contains(github.ref, 'tags/') + name: Get version + uses: jannemattila/get-version-from-tag@v3 + + - id: set_version + if: contains(github.ref, 'tags/') + name: Set version + run: VERSION=$(echo "${{ steps.get_version.outputs.version }}") + + - id: set_version + if: '!contains(github.ref, "tags/")' + name: Set version + run: VERSION=0.0.0-dev + - name: Check out winrt-go fork uses: actions/checkout@v4 with: @@ -41,7 +58,7 @@ jobs: run: go generate ./... - name: Build - run: go build -o potatodrive.exe -ldflags="-H windowsgui" ./cmd/main + run: go build -o potatodrive.exe -ldflags="-H windowsgui -X 'main.Version=$VERSION'" ./cmd/main - uses: actions/upload-artifact@v4 with: name: potatodrive.exe @@ -60,3 +77,23 @@ jobs: with: name: PotatoDrive.msi path: PotatoDrive.msi + + - name: release + uses: ncipollo/release-action@v1 + id: create_release + with: + allowUpdates: true + draft: false + prerelease: false + name: ${{ github.ref_name }} + env: + GITHUB_TOKEN: ${{ github.token }} + - name: upload HTML report + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ github.token }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: PotatoDrive.msi + asset_name: Windows 64 bit installer + asset_content_type: application/x-msi \ No newline at end of file diff --git a/cmd/main/main.go b/cmd/main/main.go index 82427c2..40971cc 100644 --- a/cmd/main/main.go +++ b/cmd/main/main.go @@ -6,12 +6,15 @@ import ( "github.com/balazsgrill/potatodrive/bindings" ) +var Version string = "0.0.0-dev" + func main() { mgr, err := New() if err != nil { log.Print(err) return } + mgr.Logger.Info().Str("version", Version).Msg("Starting PotatoDrive") ui := createUI(UIContext{ Logger: mgr.Logger, LogFile: mgr.logfilepath,