Skip to content

Commit

Permalink
chore: add ci
Browse files Browse the repository at this point in the history
  • Loading branch information
thezzisu committed Mar 19, 2024
1 parent 7fb40ca commit e1cac0b
Show file tree
Hide file tree
Showing 2 changed files with 200 additions and 0 deletions.
168 changes: 168 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
name: Release

on:
release:
types:
- prereleased
- released
push:
branches:
- main
- v*
- dev*
paths:
- '**/*.go'
- 'go.mod'
- 'go.sum'
- '.github/workflows/*.yml'
pull_request:
types: [opened, synchronize, reopened]
paths:
- '**/*.go'
- 'go.mod'
- 'go.sum'
- '.github/workflows/*.yml'

jobs:
build:
strategy:
matrix:
# Include amd64 on all platforms.
goos: [windows, freebsd, openbsd, linux, dragonfly, darwin]
goarch: [amd64, 386]
exclude:
# Exclude i386 on darwin and dragonfly.
- goarch: 386
goos: dragonfly
- goarch: 386
goos: darwin
include:
# BEGIN Linux ARM 5 6 7
- goos: linux
goarch: arm
goarm: 7
- goos: linux
goarch: arm
goarm: 6
- goos: linux
goarch: arm
goarm: 5
# END Linux ARM 5 6 7
# BEGIN Windows ARM 7
- goos: windows
goarch: arm
goarm: 7
# END Windows ARM 7
# BEGIN FreeBSD ARM 6 7
- goos: freebsd
goarch: arm
goarm: 6
- goos: freebsd
goarch: arm
goarm: 7
# END FreeBSD ARM 6 7
# BEGIN OpenBSD ARM 6 7
- goos: openbsd
goarch: arm
goarm: 6
- goos: openbsd
goarch: arm
goarm: 7
# END OpenBSD ARM 6 7
# BEGIN Other architectures
- goos: darwin
goarch: arm64
- goos: linux
goarch: arm64
- goos: linux
goarch: riscv64
- goos: linux
goarch: loong64
- goos: windows
goarch: arm64
- goos: android
goarch: arm64
- goos: freebsd
goarch: arm64
- goos: openbsd
goarch: arm64
# BEGIN MIPS
- goos: linux
goarch: mips64
- goos: linux
goarch: mips64le
- goos: linux
goarch: mipsle
- goos: linux
goarch: mips
# END MIPS
# END Other architectures
fail-fast: false

runs-on: ubuntu-latest
env:
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
GOARM: ${{ matrix.goarm }}
CGO_ENABLED: 0

steps:
- name: Checkout codebase
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Show workflow information
id: get_filename
run: |
export _NAME=$(jq ".[\"$GOOS-$GOARCH$GOARM\"].friendlyName" -r < assets/friendly-filenames.json)
echo "GOOS: $GOOS, GOARCH: $GOARCH, GOARM: $GOARM, RELEASE_NAME: $_NAME"
echo "ASSET_NAME=$_NAME" >> $GITHUB_OUTPUT
echo "ASSET_NAME=$_NAME" >> $GITHUB_ENV
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: ^1.21

- name: Get project dependencies
run: go mod download

- name: Build Azukiiro
run: |
mkdir -p build
go build -v -o build/azukiiro -trimpath -ldflags "-s -w -buildid="
- name: Rename Windows Azukiiro
if: matrix.goos == 'windows'
run: |
cd ./build || exit 1
mv azukiiro azukiiro.exe
- name: Create ZIP archive
run: |
pushd build || exit 1
zip -9vr ../azukiiro-$ASSET_NAME.zip .
popd || exit 1
FILE=./azukiiro-$ASSET_NAME.zip
DGST=$FILE.dgst
openssl dgst -md5 $FILE | sed 's/([^)]*)//g' >>$DGST
openssl dgst -sha1 $FILE | sed 's/([^)]*)//g' >>$DGST
openssl dgst -sha256 $FILE | sed 's/([^)]*)//g' >>$DGST
openssl dgst -sha512 $FILE | sed 's/([^)]*)//g' >>$DGST
- name: Upload ZIP file to Artifacts
uses: actions/upload-artifact@v3
with:
name: azukiiro-${{ steps.get_filename.outputs.ASSET_NAME }}.zip
path: azukiiro-${{ steps.get_filename.outputs.ASSET_NAME }}.zip

- name: Upload files to GitHub release
uses: svenstaro/upload-release-action@v2
if: github.event_name == 'release'
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file_glob: true
file: ./azukiiro-${{ steps.get_filename.outputs.ASSET_NAME }}.zip*
tag: ${{ github.ref }}
overwrite: true
32 changes: 32 additions & 0 deletions assets/friendly-filenames.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"darwin-amd64": { "friendlyName": "macos-64" },
"darwin-arm64": { "friendlyName": "macos-arm64-v8a" },
"dragonfly-amd64": { "friendlyName": "dragonfly-64" },
"freebsd-386": { "friendlyName": "freebsd-32" },
"freebsd-amd64": { "friendlyName": "freebsd-64" },
"freebsd-arm6": { "friendlyName": "freebsd-arm32-v6" },
"freebsd-arm7": { "friendlyName": "freebsd-arm32-v7a" },
"freebsd-arm64": { "friendlyName": "freebsd-arm64-v8a" },
"linux-386": { "friendlyName": "linux-32" },
"linux-amd64": { "friendlyName": "linux-64" },
"linux-arm5": { "friendlyName": "linux-arm32-v5" },
"linux-arm64": { "friendlyName": "linux-arm64-v8a" },
"linux-arm6": { "friendlyName": "linux-arm32-v6" },
"linux-arm7": { "friendlyName": "linux-arm32-v7a" },
"linux-mips64le": { "friendlyName": "linux-mips64le" },
"linux-mips64": { "friendlyName": "linux-mips64" },
"linux-mipsle": { "friendlyName": "linux-mips32le" },
"linux-mips": { "friendlyName": "linux-mips32" },
"linux-riscv64": { "friendlyName": "linux-riscv64" },
"linux-loong64": { "friendlyName": "linux-loong64" },
"openbsd-386": { "friendlyName": "openbsd-32" },
"openbsd-amd64": { "friendlyName": "openbsd-64" },
"openbsd-arm6": { "friendlyName": "openbsd-arm32-v6" },
"openbsd-arm7": { "friendlyName": "openbsd-arm32-v7a" },
"openbsd-arm64": { "friendlyName": "openbsd-arm64-v8a" },
"windows-amd64": { "friendlyName": "windows-64" },
"windows-386": { "friendlyName": "windows-32" },
"windows-arm64": { "friendlyName": "windows-arm64-v8a" },
"windows-arm7": { "friendlyName": "windows-arm32-v7a" },
"android-arm64": { "friendlyName": "android-arm64-v8a" }
}

0 comments on commit e1cac0b

Please sign in to comment.