Skip to content

Commit

Permalink
(ci,chore) update release process (#161)
Browse files Browse the repository at this point in the history
  • Loading branch information
jahvon authored Sep 8, 2024
1 parent c6f6f67 commit d437226
Show file tree
Hide file tree
Showing 11 changed files with 1,012 additions and 60 deletions.
64 changes: 15 additions & 49 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -1,33 +1,13 @@
name: Release Binaries
name: Release Artifacts

on:
release:
types: [created]
push:
tags:
- "*"

jobs:
commit_version_files:
name: Commit Version Files
permissions:
contents: write
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: main
fetch-tags: true

- name: Generate Version Files
run: |
go generate ./cmd/internal/version
- name: Commit Version Files
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: "release: update version files"
branch: main

releases-matrix:
name: Release Go Binary
name: Release flow Artifacts
permissions:
contents: write
packages: write
Expand All @@ -40,34 +20,20 @@ jobs:

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: "1.22.5"

- name: Generate Version Files
run: |
go generate ./cmd/internal/version
go-version: "1.23.1"

- name: Release for Linux
uses: wangyoucao577/go-release-action@v1
if: matrix.goos == 'linux'
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
goos: ${{ matrix.goos }}
goarch: ${{ matrix.goarch }}
goversion: "1.22.5"
extra_files: LICENSE README.md
# This linux dependency is required for the clipboard package
pre_command: "apt-get update && apt-get -y install xclip"

- name: Release for MacOS
uses: wangyoucao577/go-release-action@v1
if: matrix.goos == 'darwin'
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v6
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
goos: ${{ matrix.goos }}
goarch: ${{ matrix.goarch }}
goversion: "1.22.5"
extra_files: LICENSE README.md
distribution: goreleaser
version: "~> v2"
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4 changes: 2 additions & 2 deletions .github/workflows/validate.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: "^1.22.5"
go-version: "^1.23.1"

- name: Install Go Tools
run: |
Expand Down Expand Up @@ -69,7 +69,7 @@ jobs:
- name: golangci-lint
uses: golangci/golangci-lint-action@v6
with:
version: v1.57.2
version: v1.60.3

# _____ _
# |_ _|__ ___| |_
Expand Down
5 changes: 2 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,5 @@ coverage.txt
.bin
flow
flow*.tar.gz
dist
completions/

cmd/internal/version/*.txt
dist/
80 changes: 80 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# Documentation https://goreleaser.com

# yaml-language-server: $schema=https://goreleaser.com/static/schema.json
# vim: set ts=2 sw=2 tw=0 fo=cnqoj

version: 2
before:
hooks:
- go mod tidy
- go generate ./...

builds:
- binary: flow
env:
- CGO_ENABLED=0
goos:
- linux
- darwin
goarch:
- amd64
- arm64
mod_timestamp: '{{ .CommitTimestamp }}'

gomod:
proxy: true

archives:
- format: tar.gz
files:
- LICENSE
- README.md
- completions
name_template: >-
{{ .Binary }}_
{{- .Tag }}_
{{- .Os }}_
{{- .Arch }}
brews:
- name: flow
homepage: https://flowexec.io
license: Apache-2.0
directory: Formula
repository:
owner: jahvon
name: homebrew-flow
dependencies:
- name: xclip
os: linux
install: |
bin.install "flow"
bash_completion.install "completions/flow.bash"
zsh_completion.install "completions/flow.zsh"
fish_completion.install "completions/flow.fish"
test: |
system "#{bin}/flow --version"
dockers:
- image_templates:
- ghcr.io/jahvon/flow:latest
- ghcr.io/jahvon/flow:{{.Tag}}

changelog:
sort: asc
groups:
- title: "New features"
regexp: '^(feat|\(feat.*\)):'
order: 0
- title: "Bug fixes"
regexp: '^(fix|\(fix.*\)):'
order: 1
- title: "Documentation updates"
regexp: '^(docs|\(docs.*\)):'
order: 2
- title: Others
order: 999
filters:
exclude:
- "^(chore|\\(chore\\))"
- "^(test|\\(test\\))"
23 changes: 18 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,20 @@
FROM golang:alpine
FROM golang:1.23.1-bookworm

WORKDIR /app
COPY . /app
RUN go build -o flow
WORKDIR /workspaces
ENV DISABLE_FLOW_INTERACTIVE="true"

ENTRYPOINT ["./flow"]
# TODO: replace with examples repo
ENV WORKSPACE="flow"
ENV REPO="https://github.com/jahvon/flow.git"
ENV BRANCH=""

COPY . flow
WORKDIR /workspaces/flow
RUN go build -o /usr/local/bin/flow main.go && chmod +x /usr/local/bin/flow && rm -rf /workspaces/flow

WORKDIR /workspaces
RUN if [ -z "$BRANCH" ]; then git clone $REPO .; else git clone -b $BRANCH $REPO .; fi
RUN flow init workspace $WORKSPACE . --set

ENTRYPOINT ["flow"]
CMD ["get", "workspace"]
13 changes: 13 additions & 0 deletions cmd/internal/version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ var (
buildDate string
)

const (
unknown = "unknown"
)

// GoVersion returns the version of the go runtime used to compile the binary.
var goVersion = runtime.Version()

Expand All @@ -32,6 +36,15 @@ var osArch = fmt.Sprintf("%s %s", runtime.GOOS, runtime.GOARCH)

// generateOutput return the output of the version command.
func generateOutput() string {
if gitCommit == "" {
gitCommit = unknown
}
if version == "" {
version = unknown
}
if buildDate == "" {
buildDate = unknown
}
return fmt.Sprintf(`
Version: %s
Expand Down
Loading

0 comments on commit d437226

Please sign in to comment.