|
| 1 | +name: Continuous Deployment |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - "v*.*.*" |
| 7 | + |
| 8 | +jobs: |
| 9 | + publish-github: |
| 10 | + name: Publish on GitHub |
| 11 | + runs-on: ${{ matrix.config.OS }} |
| 12 | + strategy: |
| 13 | + fail-fast: false |
| 14 | + matrix: |
| 15 | + config: |
| 16 | + - { OS: ubuntu-latest, TARGET: "x86_64-unknown-linux-gnu" } |
| 17 | + - { OS: ubuntu-latest, TARGET: "x86_64-unknown-linux-musl" } |
| 18 | + - { OS: ubuntu-latest, TARGET: "i686-unknown-linux-gnu" } |
| 19 | + - { OS: ubuntu-latest, TARGET: "i686-unknown-linux-musl" } |
| 20 | + - { OS: ubuntu-latest, TARGET: "armv5te-unknown-linux-gnueabi" } |
| 21 | + - { OS: ubuntu-latest, TARGET: "armv7-unknown-linux-gnueabihf" } |
| 22 | + - { OS: ubuntu-latest, TARGET: "aarch64-unknown-linux-gnu" } |
| 23 | + - { OS: ubuntu-latest, TARGET: "aarch64-unknown-linux-musl" } |
| 24 | + - { OS: macos-latest, TARGET: "x86_64-apple-darwin" } |
| 25 | + - { OS: macos-latest, TARGET: "aarch64-apple-darwin" } |
| 26 | + - { OS: windows-latest, TARGET: "x86_64-pc-windows-msvc" } |
| 27 | + - { OS: windows-latest, TARGET: "i686-pc-windows-msvc" } |
| 28 | + |
| 29 | + steps: |
| 30 | + - name: Checkout the repository |
| 31 | + uses: actions/checkout@v3 |
| 32 | + |
| 33 | + - name: Set the release version |
| 34 | + shell: bash |
| 35 | + run: echo "RELEASE_VERSION=${GITHUB_REF:11}" >> $GITHUB_ENV |
| 36 | + |
| 37 | + - name: Install Rust |
| 38 | + uses: actions-rs/toolchain@v1 |
| 39 | + with: |
| 40 | + toolchain: stable |
| 41 | + target: ${{ matrix.config.TARGET }} |
| 42 | + override: true |
| 43 | + |
| 44 | + - name: Build |
| 45 | + uses: actions-rs/cargo@v1 |
| 46 | + with: |
| 47 | + use-cross: true |
| 48 | + command: build |
| 49 | + args: --release --locked --target ${{ matrix.config.TARGET }} |
| 50 | + |
| 51 | + - name: Prepare release assets |
| 52 | + shell: bash |
| 53 | + run: | |
| 54 | + mkdir release/ |
| 55 | + cp {LICENSE,README.md} release/ |
| 56 | + cp target/${{ matrix.config.TARGET }}/release/rustycli release/ |
| 57 | + mv release/ rustycli-${{ env.RELEASE_VERSION }}/ |
| 58 | +
|
| 59 | + - name: Create release artifacts |
| 60 | + shell: bash |
| 61 | + run: | |
| 62 | + if [ "${{ matrix.config.OS }}" = "windows-latest" ]; then |
| 63 | + 7z a -tzip "rustycli-${{ env.RELEASE_VERSION }}-${{ matrix.config.TARGET }}.zip" \ |
| 64 | + rustycli-${{ env.RELEASE_VERSION }} |
| 65 | + else |
| 66 | + tar -czvf rustycli-${{ env.RELEASE_VERSION }}-${{ matrix.config.TARGET }}.tar.gz \ |
| 67 | + rustycli-${{ env.RELEASE_VERSION }}/ |
| 68 | + shasum -a 512 rustycli-${{ env.RELEASE_VERSION }}-${{ matrix.config.TARGET }}.tar.gz \ |
| 69 | + > rustycli-${{ env.RELEASE_VERSION }}-${{ matrix.config.TARGET }}.tar.gz.sha512 |
| 70 | + fi |
| 71 | +
|
| 72 | + - name: Upload the release |
| 73 | + uses: svenstaro/upload-release-action@v2 |
| 74 | + with: |
| 75 | + repo_token: ${{ secrets.GITHUB_TOKEN }} |
| 76 | + file: rustycli-${{ env.RELEASE_VERSION }}-${{ matrix.config.TARGET }}.* |
| 77 | + file_glob: true |
| 78 | + overwrite: true |
| 79 | + tag: ${{ github.ref }} |
| 80 | + |
| 81 | + publish-crates-io: |
| 82 | + name: Publish on crates.io |
| 83 | + needs: publish-github |
| 84 | + runs-on: ubuntu-latest |
| 85 | + steps: |
| 86 | + - name: Checkout the repository |
| 87 | + uses: actions/checkout@v3 |
| 88 | + |
| 89 | + - name: Publish |
| 90 | + uses: actions-rs/cargo@v1 |
| 91 | + with: |
| 92 | + command: publish |
| 93 | + args: --locked --token ${{ secrets.CARGO_TOKEN }} |
0 commit comments