|
| 1 | +name: Release |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + release_tag: |
| 7 | + description: 'The version to release starting with `v`' |
| 8 | + required: true |
| 9 | + type: string |
| 10 | + |
| 11 | + release_ref: |
| 12 | + description: 'The branch, tag or SHA to checkout (default to latest)' |
| 13 | + default: '' |
| 14 | + type: string |
| 15 | + |
| 16 | +jobs: |
| 17 | + create-release: |
| 18 | + name: Create release |
| 19 | + runs-on: ubuntu-latest |
| 20 | + |
| 21 | + outputs: |
| 22 | + upload_url: ${{ steps.create_release.outputs.upload_url }} |
| 23 | + |
| 24 | + steps: |
| 25 | + - uses: actions/checkout@v3 |
| 26 | + |
| 27 | + - name: Create tag |
| 28 | + run: | |
| 29 | + if [ ! $(git tag -l ${{ inputs.release_tag }}) ]; then |
| 30 | + git tag ${{ inputs.release_tag }} |
| 31 | + git push origin ${{ inputs.release_tag }} |
| 32 | + fi |
| 33 | +
|
| 34 | + - name: Create release |
| 35 | + id: create_release |
| 36 | + uses: actions/create-release@v1 |
| 37 | + env: |
| 38 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 39 | + with: |
| 40 | + tag_name: ${{ inputs.release_tag }} |
| 41 | + release_name: ${{ inputs.release_tag }} |
| 42 | + draft: false |
| 43 | + |
| 44 | + build: |
| 45 | + needs: create-release |
| 46 | + |
| 47 | + strategy: |
| 48 | + fail-fast: false |
| 49 | + matrix: |
| 50 | + include: |
| 51 | + - os: windows-latest |
| 52 | + artifact-name: darklua-windows-x86_64 |
| 53 | + cargo-target: x86_64-pc-windows-msvc |
| 54 | + |
| 55 | + - os: ubuntu-18.04 |
| 56 | + artifact-name: darklua-linux-x86_64 |
| 57 | + cargo-target: x86_64-unknown-linux-gnu |
| 58 | + |
| 59 | + - os: ubuntu-18.04 |
| 60 | + artifact-name: darklua-linux-aarch64 |
| 61 | + cargo-target: aarch64-unknown-linux-gnu |
| 62 | + linker: gcc-aarch64-linux-gnu |
| 63 | + |
| 64 | + - os: macos-latest |
| 65 | + artifact-name: darklua-macos-x86_64 |
| 66 | + cargo-target: x86_64-apple-darwin |
| 67 | + |
| 68 | + - os: macos-latest |
| 69 | + artifact-name: darklua-macos-aarch64 |
| 70 | + cargo-target: aarch64-apple-darwin |
| 71 | + |
| 72 | + name: Build darklua (${{ matrix.artifact-name }}) |
| 73 | + runs-on: ${{ matrix.os }} |
| 74 | + |
| 75 | + steps: |
| 76 | + - uses: actions/checkout@v3 |
| 77 | + with: |
| 78 | + ref: ${{ inputs.release_ref }} |
| 79 | + |
| 80 | + - name: Install Rust |
| 81 | + uses: actions-rs/toolchain@v1 |
| 82 | + with: |
| 83 | + toolchain: stable |
| 84 | + target: ${{ matrix.cargo-target }} |
| 85 | + override: true |
| 86 | + profile: minimal |
| 87 | + |
| 88 | + - name: Install linker |
| 89 | + if: ${{ matrix.linker != '' }} |
| 90 | + run: | |
| 91 | + sudo apt update |
| 92 | + sudo apt install ${{ matrix.linker }} |
| 93 | + if [ ! -f ".cargo/config.toml" ]; then |
| 94 | + mkdir .cargo |
| 95 | + echo "[target.aarch64-unknown-linux-gnu]" > .cargo/config.toml |
| 96 | + echo 'linker = "aarch64-linux-gnu-gcc"' >> .cargo/config.toml |
| 97 | + fi |
| 98 | +
|
| 99 | + - name: Build darklua binary |
| 100 | + run: cargo build --locked --release --target ${{ matrix.cargo-target }} |
| 101 | + env: |
| 102 | + CARGO_TARGET_DIR: output |
| 103 | + |
| 104 | + - name: Setup archive |
| 105 | + shell: bash |
| 106 | + run: | |
| 107 | + mkdir -p staging |
| 108 | + if [ "${{ matrix.os }}" = "windows-latest" ]; then |
| 109 | + cp "output/${{ matrix.cargo-target }}/release/darklua.exe" staging/ |
| 110 | + cd staging |
| 111 | + 7z a ../release.zip * |
| 112 | + else |
| 113 | + cp "output/${{ matrix.cargo-target }}/release/darklua" staging/ |
| 114 | + cd staging |
| 115 | + zip ../release.zip * |
| 116 | + fi |
| 117 | +
|
| 118 | + - name: Upload archive |
| 119 | + uses: actions/upload-artifact@v3 |
| 120 | + with: |
| 121 | + name: ${{ matrix.artifact-name }} |
| 122 | + path: release.zip |
| 123 | + |
| 124 | + - name: Upload Binary to Release |
| 125 | + uses: actions/upload-release-asset@v1 |
| 126 | + env: |
| 127 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 128 | + with: |
| 129 | + upload_url: ${{ needs.create-release.outputs.upload_url }} |
| 130 | + asset_path: release.zip |
| 131 | + asset_name: ${{ matrix.artifact-name }}.zip |
| 132 | + asset_content_type: application/zip |
0 commit comments