Skip to content

Merge branch 'UGREEN-DEV' into UGREEN #34

Merge branch 'UGREEN-DEV' into UGREEN

Merge branch 'UGREEN-DEV' into UGREEN #34

Workflow file for this run

name: UGREEN
on:
workflow_dispatch:
push:
branches:
- UGREEN
paths:
- version
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
goarch: [amd64, arm64]
steps:
- uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.22.5'
- name: Get version from file
id: get_version
run: |
echo "version=$(cat version)" >> $GITHUB_ENV
- name: Build
run: CGO_ENABLED=0 GOARCH=${{ matrix.goarch }} go build -a --trimpath -ldflags="-w -s -X 'github.com/onlyLTY/dockerCopilot/internal/config.Version=${{ env.version }}' -X 'github.com/onlyLTY/dockerCopilot/internal/config.BuildDate=$(date)'" -o dockerCopilot-new .
- name: Compress binary
run: |
tar -czvf dockerCopilot-${{ matrix.goarch }}.tar.gz dockerCopilot-new
- name: List current directory
run: ls -la
- name: Check if release already exists
id: check_release
run: |
exists=$(gh release view ${{ env.version }} 2>&1 | grep "release not found" || true)
if [[ -z "$exists" ]]; then
echo "Release exists"
echo "RELEASE_EXISTS=true" >> $GITHUB_ENV
else
echo "Release does not exist"
echo "RELEASE_EXISTS=false" >> $GITHUB_ENV
fi
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create GitHub Release if not exists
if: env.RELEASE_EXISTS == 'false'
run: |
gh release create ${{ env.version }} \
--title "${{ env.version }}" \
--notes "Release of version ${{ env.version }}"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload Asset for ${{ matrix.goarch }}
run: |
gh release upload ${{ env.version }} dockerCopilot-${{ matrix.goarch }}.tar.gz
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}