Skip to content

Commit

Permalink
update te buiuld file
Browse files Browse the repository at this point in the history
  • Loading branch information
h0tak88r committed Feb 4, 2025
1 parent b54a43c commit ca5326f
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 112 deletions.
Binary file added ._.goreleaser.yml
Binary file not shown.
Binary file added .github/workflows/._build.yml
Binary file not shown.
126 changes: 14 additions & 112 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,129 +2,31 @@ name: Build and Release

on:
push:
branches: [main]
tags:
- 'v*'
pull_request:
- '*'

jobs:
build:
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
include:
- os: ubuntu-latest
output_name: apkx
asset_name: apkx-linux-amd64
- os: windows-latest
output_name: apkx.exe
asset_name: apkx-windows-amd64
- os: macos-latest
output_name: apkx
asset_name: apkx-darwin-amd64

runs-on: ${{ matrix.os }}
goreleaser:
runs-on: ubuntu-latest
steps:
- name: Checkout code
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.21'

- name: Set up Java
uses: actions/setup-java@v3
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v5
with:
distribution: 'temurin'
java-version: '11'

- name: Build
run: |
go mod tidy
mkdir -p dist
go build -v -o dist/${{ matrix.output_name }} ./cmd/apkx/main.go
distribution: goreleaser
version: latest
args: release --clean
env:
CGO_ENABLED: 0
GOOS: ${{ runner.os == 'Windows' && 'windows' || runner.os == 'macOS' && 'darwin' || 'linux' }}
GOARCH: amd64

- name: Test
run: go test -v ./...

- name: Prepare Release Files
if: github.event_name == 'push'
run: |
# Create directories
mkdir -p release
mkdir -p release/config
# Copy binary
cp dist/${{ matrix.output_name }} release/
# Create minimal config if not exists
if [ ! -f "config/regexes.yaml" ]; then
echo "patterns:" > release/config/regexes.yaml
echo " - name: example" >> release/config/regexes.yaml
echo " regex: 'example'" >> release/config/regexes.yaml
else
cp -r config/* release/config/
fi
# Create minimal README if not exists
if [ ! -f "README.md" ]; then
echo "# apkX" > release/README.md
echo "APK analysis tool" >> release/README.md
else
cp README.md release/
fi
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

# Create minimal LICENSE if not exists
if [ ! -f "LICENSE" ]; then
echo "MIT License" > release/LICENSE
echo "Copyright (c) $(date +%Y)" >> release/LICENSE
else
cp LICENSE release/
fi
shell: bash

- name: Create Archive
if: github.event_name == 'push'
run: |
cd release
if [ "${{ runner.os }}" = "Windows" ]; then
7z a ../${{ matrix.asset_name }}.zip ./*
else
tar czf ../${{ matrix.asset_name }}.tar.gz ./*
fi
shell: bash

- name: Upload Build Artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.asset_name }}
path: ${{ matrix.asset_name }}.*
retention-days: 7

release:
needs: build
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Download Artifacts
uses: actions/download-artifact@v4

- name: Create Release
uses: softprops/action-gh-release@v1
with:
files: |
apkx-linux-amd64.tar.gz
apkx-windows-amd64.zip
apkx-darwin-amd64.tar.gz
draft: false
prerelease: false
generate_release_notes: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
permissions:
contents: write
39 changes: 39 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
before:
hooks:
- go mod tidy

builds:
- main: ./cmd/apkx/main.go
binary: apkx
env:
- CGO_ENABLED=0
goos:
- linux
- windows
- darwin
goarch:
- amd64
- arm64
ldflags:
- -s -w

archives:
- format_overrides:
- goos: windows
format: zip
files:
- README.md
- LICENSE
- config/**/*

checksum:
name_template: 'checksums.txt'

changelog:
sort: asc
filters:
exclude:
- '^docs:'
- '^test:'
- Merge pull request
- Merge branch

0 comments on commit ca5326f

Please sign in to comment.