v1.0.11 #25
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Github Actions: alice builder | |
name: alice builder | |
on: | |
release: | |
types: | |
- created | |
workflow_dispatch: | |
concurrency: production | |
jobs: | |
parse_phase: | |
name: Get build tag for further artifact pushing | |
runs-on: ubuntu-latest | |
env: | |
JOB_REF: ${{ github.ref }} | |
outputs: | |
BUILD_TAG: ${{ steps.tag-selector.outputs.BUILD_TAG }} | |
BUILD_GOTAG: ${{ steps.gotag-selector.outputs.BUILD_GOTAG }} | |
BUILD_GOTIME: ${{ steps.gotime-selector.outputs.BUILD_GOTIME }} | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
ref: ${{ github.ref }} | |
- id: tag-selector | |
run: echo "BUILD_TAG=${GITHUB_REF#refs/*/}" >> "$GITHUB_OUTPUT" | |
- id: gotag-selector | |
run: echo "BUILD_GOTAG=$(git describe --long | sed 's/\([^-]*-g\)/r\1/;s/-/./g')" >> "$GITHUB_OUTPUT" | |
- id: gotime-selector | |
run: echo "BUILD_GOTIME=$(date --rfc-3339=seconds)" >> "$GITHUB_OUTPUT" | |
- run: | | |
cat <<-EOF | |
Github Actions outputs debug: | |
BUILD_TAG: ${{ steps.tag-selector.outputs.BUILD_TAG }} | |
BUILD_GOTAG: ${{ steps.gotag-selector.outputs.BUILD_GOTAG }} | |
BUILD_GOTIME: ${{ steps.gotime-selector.outputs.BUILD_GOTIME }} | |
EOF | |
docker_build_by_depot_phase: | |
name: Build standalone binary and docker image | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
pull-requests: write | |
repository-projects: write | |
id-token: write | |
# Allows pushing to the GitHub Container Registry | |
packages: write | |
needs: [ parse_phase ] | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: depot/setup-action@v1 | |
- uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
# https://github.community/t/additional-function-s-lowercase-uppercase/140632 | |
- name: lowercase repository name | |
run: | | |
echo "GH_LWREPONAME=${GITHUB_REPOSITORY,,}" >>${GITHUB_ENV} | |
- uses: depot/build-push-action@v1 | |
with: | |
push: true | |
project: ${{ secrets.DEPOT_PROJECT }} | |
tags: ghcr.io/${{ env.GH_LWREPONAME }}:${{ needs.parse_phase.outputs.BUILD_TAG }} | |
build-args: | | |
GOAPP_MAIN_VERSION=${{ needs.parse_phase.outputs.BUILD_GOTAG }} | |
GOAPP_MAIN_BUILDTIME=${{ needs.parse_phase.outputs.BUILD_GOTIME }} | |
- name: Telegram notify | |
run: | | |
cat <<- EOF | /usr/bin/curl -s -XPOST "https://api.telegram.org/${{ secrets.TGRM_BOT_SECRET }}/sendMessage" \ | |
-d chat_id="${{ secrets.TGRM_CHAT_ID }}" -d text="$(cat /dev/stdin)" &>/dev/null | |
ALICE Builder (Github Actions) | |
Build ${{ github.run_number }} of job ${{ github.workflow }} has been completed. | |
Builded commit: ${{ github.sha }} | |
EOF | |
matrix_binary_build_pahse: | |
name: Build standalone binaries for linux. windows, mac OS | |
runs-on: ubuntu-latest | |
needs: [ parse_phase ] | |
strategy: | |
max-parallel: 20 # github free plan value | |
matrix: | |
goos: ["linux", "windows", "darwin"] | |
goarch: ["386", "amd64"] | |
include: # I think it's true tone build for A* and M1 processes | |
- goos: darwin | |
goarch: arm64 | |
- goos: windows | |
goarch: 386 | |
extention: .exe | |
- goos: windows | |
goarch: amd64 | |
extention: .exe | |
exclude: | |
- goos: darwin | |
goarch: 386 | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-go@v4 | |
with: | |
go-version: 1.19.10 | |
- name: Install upx | |
run: sudo apt-get install -y upx | |
- name: Download all required imports | |
run: go mod download | |
- name: Build source code for ${{ matrix.goos }} ${{ matrix.goarch }} | |
run: go build -trimpath -ldflags="-s -w -X 'main.version=${{ needs.parse_phase.outputs.BUILD_GOTAG }}' -X 'main.buildtime=${{ needs.parse_phase.outputs.BUILD_GOTIME }}'" -o ./alice-${{ matrix.goos }}.${{ matrix.goarch }}${{ matrix.extention }} cmd/alice/main.go cmd/alice/flags.go | |
env: | |
GOOS: ${{ matrix.goos }} | |
GOARCH: ${{ matrix.goarch }} | |
- name: Compress binary | |
run: upx -9 -k ./alice-${{ matrix.goos }}.${{ matrix.goarch }}${{ matrix.extention }} | |
- name: Upload release asset | |
uses: softprops/action-gh-release@v1 | |
with: | |
tag_name: ${{ needs.parse_phase.outputs.BUILD_TAG }} | |
files: ./alice-${{ matrix.goos }}.${{ matrix.goarch }}${{ matrix.extention }} |