Skip to content

Commit

Permalink
test goreleaser
Browse files Browse the repository at this point in the history
Signed-off-by: allan716 <525223688@qq.com>
  • Loading branch information
allanpk716 committed Jun 28, 2021
1 parent 14a69f8 commit e8cfe15
Show file tree
Hide file tree
Showing 2 changed files with 102 additions and 42 deletions.
72 changes: 50 additions & 22 deletions .github/workflows/manual_test.yml
@@ -1,36 +1,64 @@
# This is a basic workflow that is manually triggered
name: goreleaser

name: Manual workflow

# Controls when the action will run. Workflow runs when manually triggered using the UI
# or API.
on:
workflow_dispatch:
# Inputs the workflow accepts.
inputs:
name:
# Friendly description to be shown in the UI instead of 'name'
description: 'Person to greet'
description: 'Test Cross-compiles'
# Default value if no value is explicitly provided
default: 'World'
default: 'Windows'
# Input has to be provided for the workflow to run
required: true

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "greet"
greet:
# The type of runner that the job will run on
goreleaser:
runs-on: ubuntu-latest

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Runs a single command using the runners shell
- name: Send greeting
run: echo "Hello ${{ github.event.inputs.name }}"

# 获取 tag 版本
- name: Set Version
id: set-version
run: |
echo "::set-output name=version::${GITHUB_REF:10}"
echo "ReleaseTag=${GITHUB_REF:10}"
- name: Set Version
id: set-version
run: |
echo "::set-output name=version::${GITHUB_REF:11}"
echo "ReleaseTag=${GITHUB_REF:11}"
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: change app version
run: |
# sed -i.bak 's/aabbcc/${{ steps.set-version.outputs.version }}/g' .goreleaser.yml
# rm -f .goreleaser.yml.bak
# sed -i.bak 's/aabbcc/${{ steps.set-version.outputs.version }}/g' Makefile
# sed -i.bak 's/aabbcc/${{ steps.set-version.outputs.version }}/g' Makefile.cross-compiles
- name: Create Release
id: create_release
env:
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
GO111MODULE: "on"
run: docker run -e DOCKER_USERNAME=$DOCKER_USERNAME -e DOCKER_PASSWORD=$DOCKER_PASSWORD -e GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }} --rm --privileged -v $GITHUB_WORKSPACE:/go/src/github.com/allanpk716/chinesesubfinder -v /var/run/docker.sock:/var/run/docker.sock -w /go/src/github.com/allanpk716/chinesesubfinder neilotoole/xcgo goreleaser --rm-dist




# - name: Set up Go
# uses: actions/setup-go@v2
# with:
# go-version: 1.16

# - run: |
# # https://github.com/actions/setup-go/issues/107
# cp -f `which go` /usr/bin/go

# - name: Run GoReleaser
# uses: goreleaser/goreleaser-action@v2
# with:
# version: latest
# args: release --rm-dist
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
72 changes: 52 additions & 20 deletions .goreleaser.yml
@@ -1,29 +1,61 @@
# This is an example goreleaser.yaml file with some sane defaults.
# Make sure to check the documentation at http://goreleaser.com
project_name: chinesesubfinder

env:
- GO111MODULE=on

before:
hooks:
# you may remove this if you don't use vgo
- go mod tidy
# you may remove this if you don't need go generate
# - go generate ./...
builds:
- env:
- id: chinesesubfinder-win-x64
ldflags: -s -w -X main.appVersion=aabbcc
# brew install mingw-w64
main: ./main.go
env:
- CGO_ENABLED=1
goos:
- CC=x86_64-w64-mingw32-gcc
- CC=x86_64-w64-mingw32-gcc
- CXX=x86_64-w64-mingw32-g++
goos:
- windows
goarch:
goarch:
- amd64

- id: chinesesubfinder-linux-x64
ldflags: -s -w -X main.appVersion=aabbcc
# brew install FiloSottile/musl-cross/musl-cross
main: ./main.go
env:
- CGO_ENABLED=1
#- CC=x86_64-linux-musl-gcc
# flags:
# - '-extldflags "-static"'
goos:
- linux
goarch:
- amd64

- id: unarr-darwin-x64
ldflags: -s -w -X main.appVersion=aabbcc
main: ./main.go
env:
- CGO_ENABLED=1
# comment CC line if releasing from macOS
#- CC=x86_64-apple-darwin14-clang
- CC=o64-clang
- CXX=o64-clang++
goos:
- darwin
goarch:
- amd64

archives:
- replacements:
darwin: Darwin
linux: Linux
windows: Windows
386: i386
amd64: x86_64
format_overrides:
- goos: windows
format: zip
- id: archive
name_template: "{{ .ProjectName }}-{{ .Version }}-{{ .Os }}-{{ .Arch }}"
replacements:
darwin: Darwin
linux: Linux
windows: Windows
amd64: x86_64
checksum:
name_template: 'checksums.txt'
snapshot:
Expand All @@ -32,5 +64,5 @@ changelog:
sort: asc
filters:
exclude:
- '^docs:'
- '^test:'
- '^docs:'
- '^test:'

0 comments on commit e8cfe15

Please sign in to comment.