|
| 1 | +name: Build release |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + cprintf_version: |
| 7 | + description: "Optional: cprintf version to use as tag_name (leave blank to use the latest remote version)" |
| 8 | + required: false |
| 9 | + release_name: |
| 10 | + description: "Optional: Custom release name (cprintf v* release)" |
| 11 | + required: false |
| 12 | + push: |
| 13 | + branches: [ "main" ] |
| 14 | + paths: |
| 15 | + - 'src/**' |
| 16 | + - 'build/**' |
| 17 | + - 'configure' |
| 18 | + - 'Makefile' |
| 19 | + pull_request: |
| 20 | + |
| 21 | +jobs: |
| 22 | + check_update: |
| 23 | + name: Check update |
| 24 | + runs-on: ubuntu-latest |
| 25 | + steps: |
| 26 | + - name: Check latest version |
| 27 | + id: check_version |
| 28 | + run: | |
| 29 | + remote_version=$(curl -L https://api.github.com/repos/Moe-hacker/cprintf/releases/latest | jq -r .tag_name) |
| 30 | + remote_name=$(curl -L https://api.github.com/repos/Moe-hacker/cprintf/releases/latest | jq -r .name) |
| 31 | + echo "remote_version=$remote_version" | tee -a $GITHUB_OUTPUT |
| 32 | + echo "remote_name=$remote_name" | tee -a $GITHUB_OUTPUT |
| 33 | + outputs: |
| 34 | + remote_version: ${{ steps.check_version.outputs.remote_version }} |
| 35 | + remote_name: ${{ steps.check_version.outputs.remote_name }} |
| 36 | + |
| 37 | + build: |
| 38 | + name: Build |
| 39 | + needs: check_update |
| 40 | + runs-on: ubuntu-latest |
| 41 | + permissions: |
| 42 | + contents: write |
| 43 | + steps: |
| 44 | + - name: Set env |
| 45 | + run: | |
| 46 | + if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then |
| 47 | + if [ -n "${{ github.event.inputs.cprintf_version }}" ]; then |
| 48 | + echo "version=${{ github.event.inputs.cprintf_version }}" | tee -a $GITHUB_ENV |
| 49 | + else |
| 50 | + echo "version=${{ needs.check_update.outputs.remote_version }}" | tee -a $GITHUB_ENV |
| 51 | + fi |
| 52 | +
|
| 53 | + if [ -n "${{ github.event.inputs.release_name }}" ]; then |
| 54 | + echo "release_name=${{ github.event.inputs.release_name }}" | tee -a $GITHUB_ENV |
| 55 | + elif [ -n "${{ github.event.inputs.cprintf_version }}" ]; then |
| 56 | + echo "release_name=${{ github.event.inputs.cprintf_version }}" | tee -a $GITHUB_ENV |
| 57 | + else |
| 58 | + echo "release_name=${{ needs.check_update.outputs.remote_name }}" | tee -a $GITHUB_ENV |
| 59 | + fi |
| 60 | + else |
| 61 | + echo "version=${{ needs.check_update.outputs.remote_version }}" | tee -a $GITHUB_ENV |
| 62 | + echo "release_name=${{ needs.check_update.outputs.remote_name }}" | tee -a $GITHUB_ENV |
| 63 | + fi |
| 64 | + echo "build_time=$(TZ=Asia/Shanghai date '+%Y%m%d%H%M')" | tee -a $GITHUB_ENV |
| 65 | +
|
| 66 | + - uses: actions/checkout@v4 |
| 67 | + - name: Build-Release |
| 68 | + run: | |
| 69 | + cd build |
| 70 | + sudo bash build-all.sh |
| 71 | +
|
| 72 | + - name: Release |
| 73 | + uses: softprops/action-gh-release@v2 |
| 74 | + with: |
| 75 | + tag_name: ${{ env.version }} |
| 76 | + name: ${{ env.release_name }} |
| 77 | + body: | |
| 78 | + This is cprintf binary release. |
| 79 | + NOTE: |
| 80 | + *-noupx means the binary is not upx compressed. |
| 81 | + cprintf use musl as libc to build by default (in alpine container), for smaller binary size and better security. |
| 82 | + But since I didn't found way to get stable musl container image for loongarch64, the binary for loongarch64 is built with glibc in debian. |
| 83 | + Build time: ${{ env.build_time }} |
| 84 | + prerelease: false |
| 85 | + files: | |
| 86 | + ${{ github.workspace }}/x86_64.tar |
| 87 | + ${{ github.workspace }}/i386.tar |
| 88 | + ${{ github.workspace }}/s390x.tar |
| 89 | + ${{ github.workspace }}/ppc64le.tar |
| 90 | + ${{ github.workspace }}/loongarch64.tar |
| 91 | + ${{ github.workspace }}/armv7.tar |
| 92 | + ${{ github.workspace }}/armhf.tar |
| 93 | + ${{ github.workspace }}/aarch64.tar |
| 94 | + ${{ github.workspace }}/riscv64.tar |
| 95 | + ${{ github.workspace }}/x86_64-noupx.tar |
| 96 | + ${{ github.workspace }}/i386-noupx.tar |
| 97 | + ${{ github.workspace }}/s390x-noupx.tar |
| 98 | + ${{ github.workspace }}/ppc64le-noupx.tar |
| 99 | + ${{ github.workspace }}/armv7-noupx.tar |
| 100 | + ${{ github.workspace }}/armhf-noupx.tar |
| 101 | + ${{ github.workspace }}/aarch64-noupx.tar |
| 102 | + ${{ github.workspace }}/riscv64-noupx.tar |
| 103 | +
|
0 commit comments