Skip to content
play

GitHub Action

Go Release Action

v1.1.12 Latest version

Go Release Action

play

Go Release Action

Build release for go

Installation

Copy and paste the following snippet into your .yml file.

              

- name: Go Release Action

uses: Mmx233/[email protected]

Learn more about this action in Mmx233/GoReleaseCli

Choose a version

GoReleaseCli

Lisense Release GoReport

English | 中文

~$ release --help-long
usage: release [<flags>] <target>

Golang build production release helper.

Flags:
  -h, --[no-]help          Show context-sensitive help (also try --help-long and
                           --help-man).
  -v, --[no-]version       Show application version.
  -j, --thread=(NumCpu+1)  How many threads to use for parallel compilation.
  -c, --compress=COMPRESS  Compress the binary into the specified format of
                           compressed file.
      --[no-]disable-default-ldflags
                           Disable ldflags added by default.
      --ldflags=LDFLAGS    Add custom ldflags.
      --[no-]soft-float    Enable soft float for mips.
      --[no-]cgo           Enable go cgo.
      --os=OS              Target os
      --arch=ARCH          Target arch.
  -d, --output="build"     Output dir path.
  -o, --name=NAME          Output binary file name.

Args:
  <target>  Target package.

🎷 Usage

CGO, soft-float, compression is disabled by default.

By default, compile for all architecture types. You can use the flags --os and --arch to specify the operating system or architecture, separated by commas. The program will automatically match valid architectures for compilation.

~$ release ./cmd/release
~$ release ./cmd/release --os linux,windows
~$ release ./cmd/release --arch amd64,386

During compilation, default ldflags include -extldflags "-static -fpic" -s -w as well as -trimpath. If additional custom ldflags are needed, you can use an additional flag to append them.

~$ release ./cmd/release --ldflags='-X main.Version=5.5.5'

~$ release ./cmd/release --disable-default-ldflags # Remove default ldflags.

When using --soft-float, a soft floating-point version will be added for all MIPS architectures.

~$ release ./cmd/release --soft-float

Compress to the specified format, dependent on the 7z library. If 7z library is not exist, it will try to use zip + zipnote or tar for different format. Currently supported formats include zip and tar.gz.

~$ release  ./cmd/release -c tar.gz

By default, the directory name of the target directory will be used, and the compilation result will be placed in the build directory. This can also be modified using flags.

~$ release ./cmd/release --output dist # Modify the output directory to be "dist"
~$ release ./cmd/release -d dist

~$ release ./cmd/release --name asd # Change the name to "asd".
~$ release ./cmd/release -o asd

🏭 Use in GitHub Action

Build in container

name: Release

on:
  push:
    tags:
      - v**
jobs:
  release_docker:
    runs-on: ubuntu-latest
    steps:

  release:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v4

      - name: Build
        uses: Mmx233/[email protected]
        with:
          target: ./cmd/derper
          compress: tar.gz
          soft-float: true

      - name: Upload assets
        uses: softprops/action-gh-release@v1
        with:
          files: build/*.tar.gz
          prerelease: false

Build in runner environment

name: Release

on:
  push:
    tags:
      - v**
jobs:
  release_docker:
    runs-on: ubuntu-latest
    steps:

  release:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v4

      - name: Setup Release Cli
        uses: robinraju/[email protected]
        with:
          repository: "Mmx233/GoReleaseCli"
          latest: true
          fileName: 'release_linux_amd64.tar.gz'
          extract: true
          out-file-path: './build/'

      - name: Build
        run: ./build/release ./cmd/derper --perm 777 -c tar.gz --soft-float --output build/output

      - name: Upload assets
        uses: softprops/action-gh-release@v1
        with:
          files: build/output/*.tar.gz
          prerelease: false