|
| 1 | +name: Release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - "v*" |
| 7 | + |
| 8 | +jobs: |
| 9 | + build: |
| 10 | + runs-on: macos-latest |
| 11 | + |
| 12 | + steps: |
| 13 | + - uses: actions/checkout@v2 |
| 14 | + - uses: actions-rs/toolchain@v1 |
| 15 | + with: |
| 16 | + toolchain: stable |
| 17 | + |
| 18 | + - name: Cache cargo registry |
| 19 | + uses: actions/cache@v1 |
| 20 | + with: |
| 21 | + path: ~/.cargo/registry |
| 22 | + key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }} |
| 23 | + - name: Cache cargo index |
| 24 | + uses: actions/cache@v1 |
| 25 | + with: |
| 26 | + path: ~/.cargo/git |
| 27 | + key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }} |
| 28 | + - name: Cache cargo build |
| 29 | + uses: actions/cache@v1 |
| 30 | + with: |
| 31 | + path: target |
| 32 | + key: ${{ runner.os }}-cargo-build-target-${{ hashFiles('**/Cargo.lock') }} |
| 33 | + |
| 34 | + - uses: actions-rs/cargo@v1 |
| 35 | + with: |
| 36 | + command: build |
| 37 | + args: --release --all-features |
| 38 | + - name: zip |
| 39 | + run: zip mfa-cli.zip target/release/mfa-cli |
| 40 | + - uses: actions/upload-artifact@v2 |
| 41 | + with: |
| 42 | + name: mfa-cli-release-${{ github.sha }} |
| 43 | + path: mfa-cli.zip |
| 44 | + |
| 45 | + create-release: |
| 46 | + needs: [ build ] |
| 47 | + runs-on: ubuntu-latest |
| 48 | + |
| 49 | + steps: |
| 50 | + - uses: actions/create-release@v1 |
| 51 | + id: create_release |
| 52 | + env: |
| 53 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 54 | + with: |
| 55 | + name: ${{ github.ref }} |
| 56 | + tag_name: ${{ github.ref }} |
| 57 | + release_name: Release ${{ github.ref }} |
| 58 | + draft: false |
| 59 | + prerelease: false |
| 60 | + |
| 61 | + - uses: actions/download-artifact@v2 |
| 62 | + with: |
| 63 | + name: mfa-cli-release-${{ github.sha }} |
| 64 | + - name: Display structure of downloaded files |
| 65 | + run: ls -R |
| 66 | + |
| 67 | + - uses: actions/upload-release-asset@v1 |
| 68 | + env: |
| 69 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 70 | + with: |
| 71 | + # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. |
| 72 | + upload_url: ${{ steps.create_release.outputs.upload_url }} |
| 73 | + asset_path: ./mfa-cli.zip |
| 74 | + asset_name: mfa-cli.zip |
| 75 | + asset_content_type: application/zip |
0 commit comments