Skip to content

NimTechnology

Trình bày các công nghệ CLOUD một cách dễ hiểu.

  • Kubernetes & Container
    • Docker
    • Kubernetes
      • Ingress
      • Pod
    • Helm Chart
    • OAuth2 Proxy
    • Isito-EnvoyFilter
    • Apache Kafka
      • Kafka
      • Kafka Connect
      • Lenses
    • Vault
    • Longhorn – Storage
    • VictoriaMetrics
    • MetalLB
    • Kong Gateway
  • CI/CD
    • ArgoCD
    • ArgoWorkflows
    • Argo Events
    • Spinnaker
    • Jenkins
    • Harbor
    • TeamCity
    • Git
      • Bitbucket
  • Coding
    • DevSecOps
    • Terraform
      • GCP – Google Cloud
      • AWS – Amazon Web Service
      • Azure Cloud
    • Golang
    • Laravel
    • Python
    • Jquery & JavaScript
    • Selenium
  • Log, Monitor & Tracing
    • DataDog
    • Prometheus
    • Grafana
    • ELK
      • Kibana
      • Logstash
  • BareMetal
    • NextCloud
  • Toggle search form

[Golang] Generate the Binary Files on Multi Architecture by Github Action

Posted on January 15, 2024March 13, 2024 By nim No Comments on [Golang] Generate the Binary Files on Multi Architecture by Github Action

Trước đó mình đã có 1 bài hướng dẫn các bạn tạo cli tool cho riêng mình bằng Golang.

[Golang] Create Your Own CLI — With Golang

Sau khi code xong chúng ta sẽ public cli.
Nhưng chúng ta không thể build Binary trên từng hệ điều hành rồi mới push chúng lên release được.

chúng ta sẽ dùng 1 lệnh và build chúng trên Multi Architecture hay còn gọi multi-arch

https://github.com/mrnim94/confluence_cli/blob/master/.github/workflows/build-and-release.yml

name: Release

on:
  push:
    tags:
      - 'v*'

jobs:
  release:
    strategy:
      matrix:
        go_version: [1.21.x]
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v4
      - name: Set up Go 1.21
        uses: actions/setup-go@v5
        with:
          go-version: ${{ matrix.go_version }}
      - name: Build with xgo
        uses: crazy-max/ghaction-xgo@v3
        with:
          xgo_version: latest
          go_version: ${{ matrix.go_version }}
          dest: build
          prefix: confluence_cli
          targets: windows/386,windows/amd64,linux/386,linux/amd64,darwin/386,darwin/amd64
          v: true
          x: false
          ldflags: -s -w
      - uses: actions/upload-artifact@v4
        with:
          name: confluence_cli
          path: build/
      - name: Create Release
        uses: ncipollo/release-action@v1
        with:
          token: ${{ secrets.MY_GITHUB_TOKEN }}
          tag: ${{ github.ref_name }}
          name: "Release ${{ github.ref_name }}"
          artifacts: "build/*"
          draft: false
          prerelease: false

Here’s an explanation of each section:

  1. Workflow Name:
    • name: Release – The name of the workflow is “Release.”
  2. Trigger Event:
    • on: push: tags: - 'v*' – This workflow is triggered when a new tag is pushed to the repository, specifically tags that start with “v” (commonly used for versioning).
  3. Jobs:
    • jobs: release: – Defines a job named “release.”
  4. Strategy:
    • strategy: matrix: go_version: [1.21.x] – This sets up a strategy to run the job with a matrix of different configurations. Here, it’s used to test against a specific version of Go (1.21.x).
  5. Run Environment:
    • runs-on: ubuntu-latest – The job will run on the latest version of Ubuntu provided by GitHub Actions.
  6. Steps:
    • The job consists of several steps, each performing specific actions:
      • Checkout Repository:
        • - uses: actions/checkout@v4 – Checks out the code in the repository so it can be used in the workflow.
      • Set up Go:
        • - name: Set up Go 1.21 – Sets up a specific Go environment (version 1.21.x as defined in the matrix).
      • Build with xgo:
        • - uses: crazy-max/ghaction-xgo@v3 – Uses the “xgo” action for cross-compiling Go applications. It builds the application for multiple platforms (Windows, Linux, Darwin) and architectures (386, amd64).
      • Upload Artifacts:
        • - uses: actions/upload-artifact@v4 – This step uploads the build artifacts (the compiled binaries) to GitHub, so they can be downloaded after the workflow completes.
      • Create Release:
        • - uses: ncipollo/release-action@v1 – This step creates a release on GitHub. It uses the tag name for the release name and uploads the build artifacts. The token is a GitHub secret used for authentication.

The workflow automates the process of building, packaging, and releasing software for different platforms whenever a new version tag is pushed. This helps in the consistent and efficient management of software release cycles.

Hãy tin mình:
When a Bash Script exceeds 50 lines, I convert it into streamlined Golang code.

Golang

Post navigation

Previous Post: [Grafana] Design Uptime based on Status History – Visualizations on Grafana
Next Post: Go exec command

More Related Articles

[Golang] Implement Job Queue inside GOlang. Golang
[Selenium] Save cookies of any website that is running on Selenium. Golang
[Helm/Golang] Install Helm chart on Kubernetes using Go. Golang
[Golang] In-Memory Cache or Local Cache with Golang. Golang
[Terminal/Huh] Build Terminal Form By golang. Golang
[Golang/Swagger] Apply Swagger to describe the information API on Golang Golang

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Tham Gia Group DevOps nhé!
Để Nim có nhiều động lực ra nhiều bài viết.
Để nhận được những thông báo mới nhất.

Recent Posts

  • [AWS/EKS] Cache Docker image to accelerate EKS container deployment. July 10, 2025
  • [Laravel] Laravel Helpful June 26, 2025
  • [VScode] Hướng dẫn điều chỉnh font cho terminal June 20, 2025
  • [WordPress] Hướng dấn gửi mail trên WordPress thông qua gmail. June 15, 2025
  • [Bitbucket] Git Clone/Pull/Push with Bitbucket through API Token. June 12, 2025

Archives

  • July 2025
  • June 2025
  • May 2025
  • April 2025
  • March 2025
  • February 2025
  • January 2025
  • December 2024
  • November 2024
  • October 2024
  • September 2024
  • August 2024
  • July 2024
  • June 2024
  • May 2024
  • April 2024
  • March 2024
  • February 2024
  • January 2024
  • December 2023
  • November 2023
  • October 2023
  • September 2023
  • August 2023
  • July 2023
  • June 2023
  • May 2023
  • April 2023
  • March 2023
  • February 2023
  • January 2023
  • December 2022
  • November 2022
  • October 2022
  • September 2022
  • August 2022
  • July 2022
  • June 2022
  • May 2022
  • April 2022
  • March 2022
  • February 2022
  • January 2022
  • December 2021
  • November 2021
  • October 2021
  • September 2021
  • August 2021
  • July 2021
  • June 2021

Categories

  • BareMetal
    • NextCloud
  • CI/CD
    • Argo Events
    • ArgoCD
    • ArgoWorkflows
    • Git
      • Bitbucket
    • Harbor
    • Jenkins
    • Spinnaker
    • TeamCity
  • Coding
    • DevSecOps
    • Golang
    • Jquery & JavaScript
    • Laravel
    • NextJS 14 & ReactJS & Type Script
    • Python
    • Selenium
    • Terraform
      • AWS – Amazon Web Service
      • Azure Cloud
      • GCP – Google Cloud
  • Kubernetes & Container
    • Apache Kafka
      • Kafka
      • Kafka Connect
      • Lenses
    • Docker
    • Helm Chart
    • Isito-EnvoyFilter
    • Kong Gateway
    • Kubernetes
      • Ingress
      • Pod
    • Longhorn – Storage
    • MetalLB
    • OAuth2 Proxy
    • Vault
    • VictoriaMetrics
  • Log, Monitor & Tracing
    • DataDog
    • ELK
      • Kibana
      • Logstash
    • Fluent
    • Grafana
    • Prometheus
  • Uncategorized
  • Admin

Copyright © 2025 NimTechnology.