Skip to content

Commit

Permalink
ci: adjusted pre-release. Updated tagged release
Browse files Browse the repository at this point in the history
  • Loading branch information
xntrik committed Mar 4, 2024
1 parent f1b30fb commit 86a1c85
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 55 deletions.
27 changes: 3 additions & 24 deletions .github/workflows/threatcl-pre-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,18 +47,6 @@ jobs:
go-version: '1.22'
- name: Set BUILD_TIME
run: echo BUILD_TIME=$(date -u +%Y%m%d-%H%M) >> ${GITHUB_ENV}
# - name: Go dev release
# uses: wangyoucao577/go-release-action@v1
# with:
# github_token: ${{ secrets.GITHUB_TOKEN }}
# goos: ${{ matrix.goos }}
# goarch: ${{ matrix.goarch }}
# release_tag: dev
# overwrite: true
# pre_command: export CGO_ENABLED=1
# project_path: cmd/threatcl
# binary_name: threatcl
# asset_name: "threatcl-${{ env.BUILD_TIME }}-${{ matrix.goos}}-${{ matrix.goarch }}"
- name: Go build
run: |
CGO_ENABLED=1 GOARCH=${{ matrix.goarch }} GOOS=${{ matrix.goos }} go build -o threatcl ./cmd/threatcl
Expand All @@ -69,7 +57,7 @@ jobs:
name: linux-pkg-${{ matrix.goarch }}
path: threatcl-${{ env.BUILD_TIME }}-${{ matrix.goos }}-${{ matrix.goarch }}.tar.gz

build-macos:
build-macos-dev:
permissions:
contents: write
needs: cleanup
Expand All @@ -85,15 +73,6 @@ jobs:
uses: actions/setup-go@v3
with:
go-version: '1.22'
# - name: OXCross for CGO Support
# run: |
# mkdir ../../osxcross
# git clone https://github.com/plentico/osxcross-target.git ../../osxcross/target
# - name: Set up clang
# uses: egor-tensin/setup-clang@v1
# with:
# version: latest
# platform: x64
- name: Set BUILD_TIME
run: echo BUILD_TIME=$(date -u +%Y%m%d-%H%M) >> ${GITHUB_ENV}
- name: Go build
Expand All @@ -111,7 +90,7 @@ jobs:
permissions:
contents: write
runs-on: ubuntu-latest
needs: [build-macos, build-dev-linux]
needs: [build-macos-dev, build-dev-linux]
steps:
- name: Download linux packages
uses: actions/download-artifact@v3
Expand Down Expand Up @@ -142,7 +121,7 @@ jobs:
osx-pkg-arm64
osx-pkg-amd64
pre-build-and-push-image:
pre-build-image-test:
runs-on: ubuntu-latest
needs: [pre-release]
permissions:
Expand Down
85 changes: 54 additions & 31 deletions .github/workflows/threatcl-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,78 +5,101 @@ on:
tags:
- "v*"

permissions:
contents: read

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
pre-release-linux:
build-linux:
permissions:
contents: write
runs-on: ubuntu-latest
strategy:
matrix:
goos: [linux]
goarch: [amd64]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v4
uses: actions/setup-go@v3
with:
go-version: '1.22'
- name: Bootstrap
run: make bootstrap
- name: Test
run: make test
- name: Package
run: make pkg-linux
- name: Set BUILD_TIME
run: echo BUILD_TIME=$(date -u +%Y%m%d-%H%M) >> ${GITHUB_ENV}
- name: Go build
run: |
CGO_ENABLED=1 GOARCH=${{ matrix.goarch }} GOOS=${{ matrix.goos }} go build -o threatcl ./cmd/threatcl
tar -zcvf threatcl-${{ env.BUILD_TIME }}-${{ matrix.goos }}-${{ matrix.goarch }}.tar.gz threatcl
- name: Upload Linux Package
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: linux-pkg
path: out/threatcl-linux-amd64.tar.gz
name: linux-pkg-${{ matrix.goarch }}
path: threatcl-${{ env.BUILD_TIME }}-${{ matrix.goos }}-${{ matrix.goarch }}.tar.gz

pre-release-osx:
build-macos:
permissions:
contents: write
runs-on: macos-latest
strategy:
matrix:
goos: [darwin]
goarch: [amd64, arm64]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v4
uses: actions/setup-go@v3
with:
go-version: '1.22'
- name: Bootstrap
run: make bootstrap
- name: Package
run: make pkg-osx
- name: Set BUILD_TIME
run: echo BUILD_TIME=$(date -u +%Y%m%d-%H%M) >> ${GITHUB_ENV}
- name: Go build
run: |
CGO_ENABLED=1 GOARCH=${{ matrix.goarch }} GOOS=${{ matrix.goos }} go build -o threatcl ./cmd/threatcl
tar -zcvf threatcl-${{ env.BUILD_TIME }}-${{ matrix.goos }}-${{ matrix.goarch }}.tar.gz threatcl
- name: Upload OSX Package
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: osx-pkg
path: out/threatcl-darwin-amd64.tar.gz
name: osx-pkg-${{ matrix.goarch }}
path: threatcl-${{ env.BUILD_TIME }}-${{ matrix.goos }}-${{ matrix.goarch }}.tar.gz

release:
permissions:
contents: write
runs-on: ubuntu-latest
needs: [pre-release-linux, pre-release-osx]
needs: [build-linux, build-macos]
steps:
- name: Download linux package
uses: actions/download-artifact@v2
- name: Download linux packages
uses: actions/download-artifact@v3
with:
name: linux-pkg-amd64
- name: Download osx arm64
uses: actions/download-artifact@v3
with:
name: linux-pkg
- name: Download osx package
uses: actions/download-artifact@v2
name: osx-pkg-arm64
- name: Download osx amd64
uses: actions/download-artifact@v3
with:
name: osx-pkg
name: osx-pkg-amd64
- name: Automatic Release
uses: "marvinpinto/action-automatic-releases@latest"
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
prerelease: false
title: "Release"
files: |
threatcl-linux-amd64.tar.gz
threatcl-darwin-amd64.tar.gz
threatcl*.tar.gz
- name: Remove artifacts
uses: geekyeggo/delete-artifact@v1
with:
name: |
linux-pkg
osx-pkg
linux-pkg-amd64
osx-pkg-arm64
osx-pkg-amd64
build-and-push-image:
runs-on: ubuntu-latest
Expand Down

0 comments on commit 86a1c85

Please sign in to comment.