|
| 1 | +on: |
| 2 | + push: |
| 3 | + tags: |
| 4 | + - "*" |
| 5 | + |
| 6 | +name: Release |
| 7 | + |
| 8 | +jobs: |
| 9 | + create-release: |
| 10 | + name: "Create Release" |
| 11 | + runs-on: ubuntu-latest |
| 12 | + outputs: |
| 13 | + upload_url: ${{ steps.create-release.outputs.upload_url }} |
| 14 | + steps: |
| 15 | + - name: Create Release |
| 16 | + id: create-release |
| 17 | + uses: actions/create-release@v1 |
| 18 | + env: |
| 19 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 20 | + with: |
| 21 | + tag_name: ${{ github.ref }} |
| 22 | + release_name: ${{ github.ref }} |
| 23 | + draft: true |
| 24 | + prerelease: false |
| 25 | + |
| 26 | + release: |
| 27 | + name: "Release" |
| 28 | + needs: create-release |
| 29 | + strategy: |
| 30 | + matrix: |
| 31 | + target: |
| 32 | + - target: x86_64-pc-windows-msvc |
| 33 | + os: windows-latest |
| 34 | + cross: false |
| 35 | + binary_path: target/x86_64-pc-windows-msvc/release/cli-candlestick-chart.exe |
| 36 | + - target: x86_64-unknown-linux-gnu |
| 37 | + os: ubuntu-latest |
| 38 | + cross: false |
| 39 | + binary_path: target/x86_64-unknown-linux-gnu/release/cli-candlestick-chart |
| 40 | + - target: x86_64-apple-darwin |
| 41 | + os: macos-latest |
| 42 | + cross: false |
| 43 | + binary_path: target/x86_64-apple-darwin/release/cli-candlestick-chart |
| 44 | + - target: armv7-unknown-linux-gnueabihf |
| 45 | + os: ubuntu-latest |
| 46 | + cross: true |
| 47 | + binary_path: target/armv7-unknown-linux-gnueabihf/release/cli-candlestick-chart |
| 48 | + - target: aarch64-unknown-linux-gnu |
| 49 | + os: ubuntu-latest |
| 50 | + cross: true |
| 51 | + binary_path: target/aarch64-unknown-linux-gnu/release/cli-candlestick-chart |
| 52 | + - target: aarch64-linux-android |
| 53 | + os: ubuntu-latest |
| 54 | + cross: true |
| 55 | + binary_path: target/aarch64-linux-android/release/cli-candlestick-chart |
| 56 | + |
| 57 | + runs-on: ${{ matrix.target.os }} |
| 58 | + steps: |
| 59 | + - name: Checkout sources |
| 60 | + uses: actions/checkout@v2 |
| 61 | + |
| 62 | + - name: Get the version |
| 63 | + id: get_version |
| 64 | + shell: bash |
| 65 | + run: echo ::set-output name=VERSION::${GITHUB_REF#refs/tags/} |
| 66 | + |
| 67 | + - name: Install stable toolchain |
| 68 | + uses: actions-rs/toolchain@v1 |
| 69 | + with: |
| 70 | + toolchain: stable |
| 71 | + target: ${{ matrix.target.target }} |
| 72 | + override: true |
| 73 | + |
| 74 | + - name: Run cargo build |
| 75 | + uses: actions-rs/cargo@v1 |
| 76 | + with: |
| 77 | + use-cross: ${{ matrix.target.cross }} |
| 78 | + command: build |
| 79 | + args: --release --bin=cli-candlestick-chart --features="serde serde_json csv clap" --release --target=${{ matrix.target.target }} |
| 80 | + |
| 81 | + - name: Copy release files |
| 82 | + shell: bash |
| 83 | + run: | |
| 84 | + mkdir package |
| 85 | + cp -R assets LICENSE README.md CHANGELOG.md package/ |
| 86 | + cp ${{ matrix.target.binary_path }} package/ |
| 87 | + - name: Create Archive |
| 88 | + shell: bash |
| 89 | + if: matrix.target.os != 'windows-latest' |
| 90 | + run: | |
| 91 | + tar czvf cli-candlestick-chart-${{ steps.get_version.outputs.VERSION }}-${{ matrix.target.target }}.tar.gz -C package/ . |
| 92 | + - name: Create Archive (Windows) |
| 93 | + if: matrix.target.os == 'windows-latest' |
| 94 | + run: | |
| 95 | + cd package; 7z.exe a ../cli-candlestick-chart-${{ steps.get_version.outputs.VERSION }}-${{ matrix.target.target }}.zip . |
| 96 | + - name: Upload Release Asset |
| 97 | + if: matrix.target.os != 'windows-latest' |
| 98 | + uses: actions/upload-release-asset@v1 |
| 99 | + env: |
| 100 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 101 | + with: |
| 102 | + upload_url: ${{ needs.create-release.outputs.upload_url }} |
| 103 | + asset_path: ./cli-candlestick-chart-${{ steps.get_version.outputs.VERSION }}-${{ matrix.target.target }}.tar.gz |
| 104 | + asset_name: cli-candlestick-chart-${{ steps.get_version.outputs.VERSION }}-${{ matrix.target.target }}.tar.gz |
| 105 | + asset_content_type: application/x-gzip |
| 106 | + |
| 107 | + - name: Upload Release Asset (Windows) |
| 108 | + if: matrix.target.os == 'windows-latest' |
| 109 | + uses: actions/upload-release-asset@v1 |
| 110 | + env: |
| 111 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 112 | + with: |
| 113 | + upload_url: ${{ needs.create-release.outputs.upload_url }} |
| 114 | + asset_path: ./cli-candlestick-chart-${{ steps.get_version.outputs.VERSION }}-${{ matrix.target.target }}.zip |
| 115 | + asset_name: cli-candlestick-chart-${{ steps.get_version.outputs.VERSION }}-${{ matrix.target.target }}.zip |
| 116 | + asset_content_type: application/zip |
| 117 | + |
| 118 | + publish: |
| 119 | + name: "Publish" |
| 120 | + runs-on: ubuntu-latest |
| 121 | + steps: |
| 122 | + - name: Checkout sources |
| 123 | + uses: actions/checkout@v2 |
| 124 | + |
| 125 | + - name: Install stable toolchain |
| 126 | + uses: actions-rs/toolchain@v1 |
| 127 | + with: |
| 128 | + toolchain: stable |
| 129 | + override: true |
| 130 | + |
| 131 | + - name: Publish cli-candlestick-chart |
| 132 | + uses: actions-rs/cargo@v1 |
| 133 | + with: |
| 134 | + command: publish |
| 135 | + args: --token ${{ secrets.CRATES_TOKEN }} |
0 commit comments