From 6a5750ad624a6f674b123d20c9dec124628d882b Mon Sep 17 00:00:00 2001 From: Pranav Gaikwad Date: Wed, 20 Mar 2024 15:48:51 -0400 Subject: [PATCH] :ghost: Add workflow to upload binaries to releases (#182) * :ghost: add workflow to upload binaries to releases Signed-off-by: Pranav Gaikwad * :ghost: wait for image to publish Signed-off-by: Pranav Gaikwad * :ghost: use manual trigger Signed-off-by: Pranav Gaikwad --------- Signed-off-by: Pranav Gaikwad --- .github/workflows/release-artifacts.yaml | 69 ++++++++++++++++++++++++ Dockerfile | 6 +-- 2 files changed, 72 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/release-artifacts.yaml diff --git a/.github/workflows/release-artifacts.yaml b/.github/workflows/release-artifacts.yaml new file mode 100644 index 0000000..f3f71a0 --- /dev/null +++ b/.github/workflows/release-artifacts.yaml @@ -0,0 +1,69 @@ +# this workflow makes sure we upload kantra binaries to release assets +name: "Upload binaries to release assets" + +on: + workflow_dispatch: + inputs: + use_latest_release: + type: boolean + default: true + description: Upload binaries to the most recent release + tag_pattern: + type: string + default: 'v*' + description: Pick from tags matching this pattern + +jobs: + resolve-and-upload: + runs-on: ${{ matrix.os }} + strategy: + matrix: + arch: ["amd64", "arm64"] + os: ["ubuntu-latest"] + steps: + - id: release_info + uses: joutvhu/get-release@v1 + with: + latest: ${{ github.event.inputs.use_latest_release }} + tag_pattern: ${{ github.event.inputs.tag_pattern }} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract binaries + run: | + image=quay.io/konveyor/kantra:${{ steps.release_info.outputs.tag_name }} + podman create --name kantra-download ${image} + podman cp kantra-download:/usr/local/bin/kantra . && zip kantra.linux.${{ matrix.arch }}.zip kantra + podman cp kantra-download:/usr/local/bin/darwin-kantra . && zip kantra.darwin.${{ matrix.arch }}.zip darwin-kantra + podman cp kantra-download:/usr/local/bin/windows-kantra windows-kantra.exe && zip kantra.windows.${{ matrix.arch }}.zip windows-kantra.exe + + - name: Upload linux binary + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.release_info.outputs.upload_url }} + asset_path: ./kantra.linux.${{ matrix.arch }}.zip + asset_name: kantra.linux.${{ matrix.arch }}.zip + asset_content_type: application/zip + + - name: Upload windows binary + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.release_info.outputs.upload_url }} + asset_path: ./kantra.windows.${{ matrix.arch }}.zip + asset_name: kantra.windows.${{ matrix.arch }}.zip + asset_content_type: application/zip + + - name: Upload darwin binary + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.release_info.outputs.upload_url }} + asset_path: ./kantra.darwin.${{ matrix.arch }}.zip + asset_name: kantra.darwin.${{ matrix.arch }}.zip + asset_content_type: application/zip + diff --git a/Dockerfile b/Dockerfile index ce25ac2..55e2b45 100644 --- a/Dockerfile +++ b/Dockerfile @@ -27,9 +27,9 @@ COPY pkg/ pkg/ # Build ARG VERSION ARG BUILD_COMMIT -RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build --ldflags="-X 'github.com/konveyor-ecosystem/kantra/cmd.Version=$VERSION' -X 'github.com/konveyor-ecosystem/kantra/cmd.BuildCommit=$BUILD_COMMIT'" -a -o kantra main.go -RUN CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build --ldflags="-X 'github.com/konveyor-ecosystem/kantra/cmd.Version=$VERSION' -X 'github.com/konveyor-ecosystem/kantra/cmd.BuildCommit=$BUILD_COMMIT'" -a -o darwin-kantra main.go -RUN CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build --ldflags="-X 'github.com/konveyor-ecosystem/kantra/cmd.Version=$VERSION' -X 'github.com/konveyor-ecosystem/kantra/cmd.BuildCommit=$BUILD_COMMIT'" -a -o windows-kantra main.go +RUN CGO_ENABLED=0 GOOS=linux go build --ldflags="-X 'github.com/konveyor-ecosystem/kantra/cmd.Version=$VERSION' -X 'github.com/konveyor-ecosystem/kantra/cmd.BuildCommit=$BUILD_COMMIT'" -a -o kantra main.go +RUN CGO_ENABLED=0 GOOS=darwin go build --ldflags="-X 'github.com/konveyor-ecosystem/kantra/cmd.Version=$VERSION' -X 'github.com/konveyor-ecosystem/kantra/cmd.BuildCommit=$BUILD_COMMIT'" -a -o darwin-kantra main.go +RUN CGO_ENABLED=0 GOOS=windows go build --ldflags="-X 'github.com/konveyor-ecosystem/kantra/cmd.Version=$VERSION' -X 'github.com/konveyor-ecosystem/kantra/cmd.BuildCommit=$BUILD_COMMIT'" -a -o windows-kantra main.go FROM quay.io/konveyor/analyzer-lsp:latest