|
| 1 | +# The way this works is the following: |
| 2 | +# |
| 3 | +# The create-release job runs purely to initialize the GitHub release itself |
| 4 | +# and to output upload_url for the following job. |
| 5 | +# |
| 6 | +# The build-release job runs only once create-release is finished. It gets the |
| 7 | +# release upload URL from create-release job outputs, then builds the release |
| 8 | +# executables for each supported platform and attaches them as release assets |
| 9 | +# to the previously created release. |
| 10 | +# |
| 11 | +# The key here is that we create the release only once. |
| 12 | +# |
| 13 | +# Reference: |
| 14 | +# https://eugene-babichenko.github.io/blog/2020/05/09/github-actions-cross-platform-auto-releases/ |
| 15 | + |
| 16 | +name: default-release |
| 17 | +on: |
| 18 | + workflow_call: |
| 19 | + workflow_dispatch: |
| 20 | + |
| 21 | +jobs: |
| 22 | + build-release: |
| 23 | + name: build-release |
| 24 | + runs-on: ubuntu-latest |
| 25 | + steps: |
| 26 | + - name: Checkout repository |
| 27 | + uses: actions/checkout@v2 |
| 28 | + with: |
| 29 | + fetch-depth: 1 |
| 30 | + - name: Cache |
| 31 | + uses: Swatinem/rust-cache@v1 |
| 32 | + - name: Install packages (Ubuntu) |
| 33 | + run: | |
| 34 | + sudo apt-get update |
| 35 | + sudo apt-get install -y gcc-multilib xz-utils liblz4-tool libc6-dev libssl-dev musl-tools pkg-config patchelf |
| 36 | + sudo apt-get install -y gcc-aarch64-linux-gnu gcc-arm-linux-gnueabihf |
| 37 | + - name: Install Rust |
| 38 | + uses: actions-rs/toolchain@v1 |
| 39 | + with: |
| 40 | + toolchain: stable |
| 41 | + profile: minimal |
| 42 | + override: true |
| 43 | + target: x86_64-unknown-linux-musl |
| 44 | + - name: Build release binary |
| 45 | + run: cargo install --git https://github.com/getzola/zola.git --features=indexing-zh |
| 46 | + - name: Build archive |
| 47 | + shell: bash |
| 48 | + run: | |
| 49 | + bin_file="~/.cargo/bin/zola" |
| 50 | + echo "BIN_FILE=$bin_file" >> $GITHUB_ENV |
| 51 | + - name: Upload binary to release |
| 52 | + uses: svenstaro/upload-release-action@v1-release |
| 53 | + with: |
| 54 | + repo_token: ${{ secrets.GITHUB_TOKEN }} |
| 55 | + file: ${{ env.BIN_FILE }} |
| 56 | + asset_name: zola |
| 57 | + tag: default |
| 58 | + overwrite: true |
0 commit comments