|
| 1 | +name: Rust |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [ master ] |
| 6 | + pull_request: |
| 7 | + branches: [ master ] |
| 8 | + |
| 9 | +env: |
| 10 | + CARGO_TERM_COLOR: always |
| 11 | + |
| 12 | +jobs: |
| 13 | + build-pam-module: |
| 14 | + name: 'Build PAM module' |
| 15 | + |
| 16 | + runs-on: ubuntu-latest |
| 17 | + |
| 18 | + steps: |
| 19 | + - uses: actions/checkout@v2 |
| 20 | + |
| 21 | + - name: Install Rust |
| 22 | + uses: actions-rs/toolchain@v1 |
| 23 | + with: |
| 24 | + toolchain: stable |
| 25 | + default: true |
| 26 | + override: true |
| 27 | + |
| 28 | + - name: Enable Rust cache |
| 29 | + uses: Swatinem/rust-cache@v1 |
| 30 | + |
| 31 | + - name: Install libpam |
| 32 | + run: sudo apt-get install libpam0g-dev |
| 33 | + |
| 34 | + - name: Build |
| 35 | + run: make clean build/pam_wsl_hello.so |
| 36 | + |
| 37 | + - uses: actions/upload-artifact@v2 |
| 38 | + name: Upload artifact |
| 39 | + with: |
| 40 | + name: 'PAM module' |
| 41 | + path: build/pam_wsl_hello.so |
| 42 | + if-no-files-found: error |
| 43 | + |
| 44 | + build-windows-binaries: |
| 45 | + name: 'Build Windows binaries' |
| 46 | + |
| 47 | + runs-on: windows-latest |
| 48 | + |
| 49 | + steps: |
| 50 | + - uses: actions/checkout@v2 |
| 51 | + |
| 52 | + - name: Add msbuild to PATH |
| 53 | + |
| 54 | + |
| 55 | + - name: Build |
| 56 | + run: make clean all |
| 57 | + working-directory: win_components |
| 58 | + |
| 59 | + - uses: actions/upload-artifact@v2 |
| 60 | + name: Upload artifacts |
| 61 | + with: |
| 62 | + name: 'Windows Binaries' |
| 63 | + path: win_components/build/ |
| 64 | + if-no-files-found: error |
| 65 | + |
| 66 | + release: |
| 67 | + name: 'Release' |
| 68 | + |
| 69 | + if: ${{ github.event_name == 'push' }} |
| 70 | + |
| 71 | + runs-on: ubuntu-latest |
| 72 | + |
| 73 | + needs: [build-pam-module, build-windows-binaries] |
| 74 | + |
| 75 | + steps: |
| 76 | + - uses: actions/checkout@v2 |
| 77 | + |
| 78 | + - uses: actions/download-artifact@v2 |
| 79 | + with: |
| 80 | + name: 'Windows Binaries' |
| 81 | + path: build |
| 82 | + |
| 83 | + - uses: actions/download-artifact@v2 |
| 84 | + with: |
| 85 | + name: 'PAM module' |
| 86 | + path: build |
| 87 | + |
| 88 | + - name: Conventional Changelog Action |
| 89 | + id: changelog |
| 90 | + uses: TriPSs/conventional-changelog-action@v3 |
| 91 | + with: |
| 92 | + github-token: ${{ secrets.github_token }} |
| 93 | + version-file: Cargo.toml |
| 94 | + version-path: package.version |
| 95 | + skip-on-empty: false |
| 96 | + git-user-name: 'github-actions[bot]' |
| 97 | + git-user-email: '41898282+github-actions[bot]@users.noreply.github.com' |
| 98 | + |
| 99 | + - name: Create Release asset |
| 100 | + id: create_asset |
| 101 | + env: |
| 102 | + release_name: WSL-Hello-sudo-${{ steps.changelog.outputs.tag }} |
| 103 | + run: | |
| 104 | + make -d release RELEASE="$release_name" |
| 105 | + echo "::set-output name=release_asset::$release_name.tar.gz" |
| 106 | +
|
| 107 | + - name: Create Release |
| 108 | + id: create_release |
| 109 | + uses: actions/create-release@v1 |
| 110 | + env: |
| 111 | + GITHUB_TOKEN: ${{ secrets.github_token }} |
| 112 | + with: |
| 113 | + tag_name: ${{ steps.changelog.outputs.tag }} |
| 114 | + release_name: ${{ steps.changelog.outputs.tag }} |
| 115 | + body: ${{ steps.changelog.outputs.clean_changelog }} |
| 116 | + |
| 117 | + - name: Upload Release Asset |
| 118 | + id: upload-release-asset |
| 119 | + uses: actions/upload-release-asset@v1 |
| 120 | + env: |
| 121 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 122 | + with: |
| 123 | + upload_url: ${{ steps.create_release.outputs.upload_url }} |
| 124 | + asset_path: ${{ steps.create_asset.outputs.release_asset }} |
| 125 | + asset_name: ${{ steps.create_asset.outputs.release_asset }} |
| 126 | + asset_content_type: application/gzip |
| 127 | + |
0 commit comments