|
| 1 | +on: |
| 2 | + push: |
| 3 | + tags: |
| 4 | + - v* |
| 5 | +permissions: |
| 6 | + contents: write |
| 7 | +name: make-release |
| 8 | +jobs: |
| 9 | + makerelease: |
| 10 | + strategy: |
| 11 | + matrix: |
| 12 | + os: [macos-latest, ubuntu-latest] |
| 13 | + name: make release |
| 14 | + runs-on: ${{ matrix.os }} |
| 15 | + steps: |
| 16 | + - uses: actions/checkout@v4 |
| 17 | + - name: 'Authenticate to Google Cloud' |
| 18 | + uses: 'google-github-actions/[email protected]' |
| 19 | + with: |
| 20 | + credentials_json: '${{ secrets.GOOGLE_CLOUD_DL_SA }}' |
| 21 | + - name: Set up Cloud SDK |
| 22 | + uses: google-github-actions/[email protected] |
| 23 | + with: |
| 24 | + project_id: zooapi |
| 25 | + - name: Install latest nightly |
| 26 | + uses: dtolnay/rust-toolchain@stable |
| 27 | + - if: ${{ matrix.os == 'ubuntu-latest' }} |
| 28 | + name: Install deps |
| 29 | + shell: bash |
| 30 | + run: | |
| 31 | + ./.github/workflows/cross-deps.sh |
| 32 | + - if: ${{ matrix.os == 'macos-latest' }} |
| 33 | + name: Install deps |
| 34 | + shell: bash |
| 35 | + run: | |
| 36 | + brew install \ |
| 37 | + coreutils \ |
| 38 | + jq |
| 39 | +
|
| 40 | + cargo install toml-cli |
| 41 | + - name: Cache cargo registry |
| 42 | + uses: actions/cache@v4 |
| 43 | + with: |
| 44 | + path: ~/.cargo/registry |
| 45 | + key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }} |
| 46 | + - name: Cache cargo index |
| 47 | + uses: actions/cache@v4 |
| 48 | + with: |
| 49 | + path: ~/.cargo/git |
| 50 | + key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }} |
| 51 | + - name: Cache cargo build |
| 52 | + uses: actions/cache@v4 |
| 53 | + with: |
| 54 | + path: target |
| 55 | + key: ${{ runner.os }}-cargo-build-target-${{ hashFiles('**/Cargo.lock') }} |
| 56 | + - name: Run make cross |
| 57 | + run: | |
| 58 | + export PATH="/usr/local/opt/coreutils/libexec/gnubin:$PATH" |
| 59 | + make release |
| 60 | + ls -la cross |
| 61 | + shell: bash |
| 62 | + - name: move files to dir for upload |
| 63 | + shell: bash |
| 64 | + run: | |
| 65 | + export VERSION=v$(toml get Cargo.toml package.version | jq -r .) |
| 66 | + mkdir -p releases/$(basename $(pwd)) |
| 67 | + cp -r cross releases/$(basename $(pwd))/${VERSION} |
| 68 | + cp cross/README.md cross/${{matrix.os}}-${{github.ref_name}}-README.md |
| 69 | + - name: 'upload binary files' |
| 70 | + id: upload-files |
| 71 | + uses: google-github-actions/[email protected] |
| 72 | + with: |
| 73 | + path: releases |
| 74 | + destination: dl.zoo.io |
| 75 | + # Store the binary artifacts for retrival later. |
| 76 | + - name: Upload artifacts |
| 77 | + uses: actions/upload-artifact@v4 |
| 78 | + with: |
| 79 | + name: release-${{ matrix.os }}-${{github.ref_name}} |
| 80 | + path: ./cross |
| 81 | + # Store the readme as an artifact so we can combine the two. |
| 82 | + - name: Archive the README.md data |
| 83 | + uses: actions/upload-artifact@v4 |
| 84 | + with: |
| 85 | + name: ${{matrix.os}}-${{github.ref_name}}-README.md |
| 86 | + path: ${{github.workspace}}/cross/${{matrix.os}}-${{github.ref_name}}-README.md |
| 87 | + createrelease: |
| 88 | + runs-on: ubuntu-latest |
| 89 | + needs: [makerelease] |
| 90 | + name: createrelease |
| 91 | + steps: |
| 92 | + - uses: actions/checkout@v4 |
| 93 | + - name: Install latest nightly |
| 94 | + uses: dtolnay/rust-toolchain@stable |
| 95 | + - uses: actions/download-artifact@v4 |
| 96 | + with: |
| 97 | + name: release-macos-latest-${{github.ref_name}} |
| 98 | + path: build |
| 99 | + - uses: actions/download-artifact@v4 |
| 100 | + with: |
| 101 | + name: release-ubuntu-latest-${{github.ref_name}} |
| 102 | + path: build |
| 103 | + - uses: actions/download-artifact@v4 |
| 104 | + with: |
| 105 | + name: ubuntu-latest-${{github.ref_name}}-README.md |
| 106 | + - uses: actions/download-artifact@v4 |
| 107 | + with: |
| 108 | + name: macos-latest-${{github.ref_name}}-README.md |
| 109 | + - name: combine readmes |
| 110 | + shell: bash |
| 111 | + run: | |
| 112 | + ls -la |
| 113 | + echo 'These instructions are meant as an easy way to install. Note: you likely need to install `coreutils` in order to have the `sha256sum` command.' > release.md |
| 114 | + echo "" >> release.md |
| 115 | + cat macos-latest-${{github.ref_name}}-README.md \ |
| 116 | + ubuntu-latest-${{github.ref_name}}-README.md \ |
| 117 | + >> release.md |
| 118 | + rm build/*-README.md |
| 119 | + rm build/README.md |
| 120 | + - name: Get if prerelease |
| 121 | + shell: bash |
| 122 | + id: extract_prerelease |
| 123 | + run: | |
| 124 | + cargo install toml-cli |
| 125 | + export VERSION=v$(toml get Cargo.toml package.version | jq -r .) |
| 126 | + if echo $VERSION | grep -q "rc"; then |
| 127 | + echo "##[set-output name=prerelease;]$(echo true)"; |
| 128 | + else |
| 129 | + if echo $VERSION | grep -q "pre"; then |
| 130 | + echo "##[set-output name=prerelease;]$(echo true)"; |
| 131 | + else |
| 132 | + echo "##[set-output name=prerelease;]$(echo false)"; |
| 133 | + fi |
| 134 | + fi |
| 135 | + - name: Create a Release |
| 136 | + uses: softprops/action-gh-release@v2 |
| 137 | + with: |
| 138 | + body_path: ${{github.workspace}}/release.md |
| 139 | + prerelease: ${{steps.extract_prerelease.outputs.prerelease}} |
| 140 | + files: ./build/* |
0 commit comments