github.com/Asutorufa/yuhaiin@v0.3.6-0.20240502055049-7984da7023a0/.github/workflows/go.yml (about) 1 name: Go 2 3 on: 4 push: 5 branches: [main] 6 tags: [v*] 7 pull_request: 8 branches: [main] 9 10 jobs: 11 package: 12 needs: [] 13 runs-on: ubuntu-latest 14 permissions: 15 packages: write 16 contents: read 17 18 steps: 19 - uses: actions/checkout@v4 20 with: 21 fetch-depth: "0" 22 fetch-tags: "true" 23 24 - name: Docker metadata 25 id: meta 26 uses: docker/metadata-action@v5 27 with: 28 images: ghcr.io/${{ github.repository }} 29 flavor: latest=true 30 tags: | 31 type=ref,event=branch 32 type=ref,event=pr 33 type=semver,pattern={{version}} 34 35 - name: Set up Go 36 uses: actions/setup-go@v5 37 with: 38 check-latest: true 39 go-version-file: "go.mod" 40 41 - name: update dep 42 run: | 43 go get -v -u github.com/yuhaiin/kitte@$(curl -H "Accept: application/vnd.github.VERSION.sha" "https://api.github.com/repos/yuhaiin/kitte/commits/main") 44 go get -v -u github.com/yuhaiin/yuhaiin.github.io@$(curl -H "Accept: application/vnd.github.VERSION.sha" "https://api.github.com/repos/yuhaiin/yuhaiin.github.io/commits/main") 45 46 - name: Login to GitHub Container Registry 47 uses: docker/login-action@v3 48 with: 49 registry: ghcr.io 50 username: ${{ github.repository_owner }} 51 password: ${{ secrets.GITHUB_TOKEN }} 52 53 - # Add support for more platforms with QEMU (optional) 54 # https://github.com/docker/setup-qemu-action 55 name: Set up QEMU 56 uses: docker/setup-qemu-action@v3 57 58 - name: Set up Docker Buildx 59 uses: docker/setup-buildx-action@v3 60 61 - name: Build and push 62 uses: docker/build-push-action@v5 63 with: 64 context: . 65 platforms: linux/amd64,linux/arm64 66 file: cmd/yuhaiin/Dockerfile 67 push: true 68 tags: ${{ steps.meta.outputs.tags }} 69 labels: ${{ steps.meta.outputs.labels }} 70 71 android: 72 needs: [] 73 runs-on: ubuntu-latest 74 75 steps: 76 - uses: actions/checkout@v4 77 with: 78 fetch-depth: "0" 79 fetch-tags: "true" 80 81 - name: Set up Go 82 uses: actions/setup-go@v5 83 with: 84 check-latest: true 85 go-version-file: "go.mod" 86 87 - name: set up JDK 17 88 uses: actions/setup-java@v4 89 with: 90 java-version: "17" 91 distribution: "temurin" 92 93 - name: build yuhaiin aar 94 run: | 95 go get -v -u github.com/yuhaiin/kitte@$(curl -H "Accept: application/vnd.github.VERSION.sha" "https://api.github.com/repos/yuhaiin/kitte/commits/main") 96 go get -v -u github.com/yuhaiin/yuhaiin.github.io@$(curl -H "Accept: application/vnd.github.VERSION.sha" "https://api.github.com/repos/yuhaiin/yuhaiin.github.io/commits/main") 97 go install golang.org/x/mobile/cmd/gomobile@latest 98 gomobile init 99 make yuhaiin_android_aar 100 101 - name: upload_android_aar 102 uses: actions/upload-artifact@v4 103 with: 104 name: yuhaiin.aar 105 path: yuhaiin.aar 106 107 build: 108 needs: [] 109 runs-on: ubuntu-latest 110 strategy: 111 fail-fast: false 112 matrix: 113 env: 114 [ 115 [linux, "amd64"], 116 [linux, "amd64v3"], 117 [linux, "arm64"], 118 [linux, "mipsle"], 119 [android, "arm64"], 120 [darwin, "amd64"], 121 [darwin, "amd64v3"], 122 [darwin, "arm64"], 123 [freebsd, "amd64"], 124 [freebsd, "amd64v3"], 125 [freebsd, "arm64"], 126 [openbsd, "amd64"], 127 [openbsd, "amd64v3"], 128 [openbsd, "arm64"], 129 [windows, "amd64"], 130 [windows, "amd64v3"], 131 [windows, "arm64"], 132 ] 133 cmd: [yuhaiin] 134 135 steps: 136 - uses: actions/checkout@v4 137 with: 138 fetch-depth: "0" 139 fetch-tags: "true" 140 141 - name: Set up Go 142 uses: actions/setup-go@v5 143 with: 144 check-latest: true 145 go-version-file: "go.mod" 146 147 # - name: Set up Upx 148 # run: | 149 # sudo apt update 150 # sudo apt install -y upx 151 152 # if [ ${{ matrix.os[0] }} != "darwin" ]; then 153 # upx --lzma --best ${{ matrix.cmd }}_${{ matrix.os[0] }}_${{ matrix.arch }}${{ matrix.os[1] }} 154 # fi 155 - name: Build 156 env: 157 GOOS: ${{ matrix.env[0] }} 158 GOARCH: ${{ matrix.env[1] == 'amd64v3' && 'amd64' || matrix.env[1] }} 159 GOAMD64: ${{ matrix.env[1] == 'amd64v3' && 'v3' || '' }} 160 GOMIPS: ${{ matrix.env[1] == 'mipsle' && 'softfloat' || '' }} 161 run: | 162 go get -v -u github.com/yuhaiin/kitte@$(curl -H "Accept: application/vnd.github.VERSION.sha" "https://api.github.com/repos/yuhaiin/kitte/commits/main") 163 go get -v -u github.com/yuhaiin/yuhaiin.github.io@$(curl -H "Accept: application/vnd.github.VERSION.sha" "https://api.github.com/repos/yuhaiin/yuhaiin.github.io/commits/main") 164 make ${{ matrix.cmd }} 165 166 - name: upload_${{ matrix.cmd }}_${{ matrix.env[0] }}_${{ matrix.env[1] }} 167 uses: actions/upload-artifact@v4 168 with: 169 name: ${{ matrix.cmd }}_${{ matrix.env[0] }}_${{ matrix.env[1] }} 170 path: | 171 ${{ matrix.cmd == 'yuhaiin_lite' && 'yuhaiin' || matrix.cmd }}${{ matrix.env[0] == 'windows' && '.exe' || '' }}