|
| 1 | +name: Build Release |
| 2 | + |
| 3 | +on: |
| 4 | + # This will trigger when a tag like v1.0.0 is pushed |
| 5 | + # will create a release |
| 6 | + push: |
| 7 | + tags: |
| 8 | + - "*.*.*" |
| 9 | + # Manual trigger for creating an artifact (button in the UI) |
| 10 | + workflow_dispatch: |
| 11 | + |
| 12 | +permissions: |
| 13 | + packages: write |
| 14 | + contents: write |
| 15 | + |
| 16 | +jobs: |
| 17 | + build: |
| 18 | + name: Build |
| 19 | + runs-on: ubuntu-latest |
| 20 | + steps: |
| 21 | + # Checkout the repo for building |
| 22 | + - uses: actions/checkout@v4 |
| 23 | + |
| 24 | + # Setup rust for building the service |
| 25 | + - name: Set up Rust |
| 26 | + uses: dtolnay/rust-toolchain@stable |
| 27 | + with: |
| 28 | + toolchain: stable |
| 29 | + targets: ${{ matrix.target }} |
| 30 | + override: true |
| 31 | + |
| 32 | + # Install zig for cargo lambda |
| 33 | + - name: Install zig |
| 34 | + run: pip3 install ziglang |
| 35 | + |
| 36 | + # Install cargo lambda |
| 37 | + - name: Install cargo-lambda |
| 38 | + run: curl -fsSL https://cargo-lambda.info/install.sh | sh |
| 39 | + |
| 40 | + # Compile the lambda binaries |
| 41 | + - name: Build lambda binaries |
| 42 | + run: cargo lambda build --output-format zip --release |
| 43 | + |
| 44 | + # Copy built binary to output directory |
| 45 | + - name: Copy binary to output |
| 46 | + run: | |
| 47 | + cp target/lambda/docbox-http-lambda/bootstrap.zip docbox-http-lambda.zip |
| 48 | + cp target/lambda/docbox-presigned-cleanup-lambda/bootstrap.zip docbox-presigned-cleanup-lambda.zip |
| 49 | + cp target/lambda/docbox-upload-completion-lambda/bootstrap.zip docbox-upload-completion-lambda.zip |
| 50 | + shell: bash |
| 51 | + |
| 52 | + # Upload the built artifacts |
| 53 | + - name: Upload docbox-http-lambda.zip |
| 54 | + uses: actions/upload-artifact@v4 |
| 55 | + with: |
| 56 | + name: docbox-http-lambda.zip |
| 57 | + path: docbox-http-lambda.zip |
| 58 | + |
| 59 | + - name: Upload docbox-presigned-cleanup-lambda.zip |
| 60 | + uses: actions/upload-artifact@v4 |
| 61 | + with: |
| 62 | + name: docbox-presigned-cleanup-lambda.zip |
| 63 | + path: docbox-presigned-cleanup-lambda.zip |
| 64 | + |
| 65 | + - name: Upload docbox-upload-completion-lambda.zip |
| 66 | + uses: actions/upload-artifact@v4 |
| 67 | + with: |
| 68 | + name: docbox-upload-completion-lambda.zip |
| 69 | + path: docbox-upload-completion-lambda.zip |
| 70 | + |
| 71 | + release: |
| 72 | + name: Create Release |
| 73 | + runs-on: ubuntu-latest |
| 74 | + needs: [build] |
| 75 | + |
| 76 | + steps: |
| 77 | + # Checkout the repo |
| 78 | + - uses: actions/checkout@v4 |
| 79 | + |
| 80 | + # Download all the compiled artifacts from previous |
| 81 | + # steps |
| 82 | + - name: Download all build artifacts |
| 83 | + uses: actions/download-artifact@v4 |
| 84 | + with: |
| 85 | + path: dist |
| 86 | + merge-multiple: true |
| 87 | + |
| 88 | + # Create the github release if we pushed up a new tag |
| 89 | + - name: Create GitHub Release |
| 90 | + uses: softprops/action-gh-release@v2 |
| 91 | + if: github.event_name == 'push' |
| 92 | + with: |
| 93 | + tag_name: ${{ github.ref_name }} |
| 94 | + name: v${{ github.ref_name }} |
| 95 | + draft: true |
| 96 | + files: dist/* |
| 97 | + env: |
| 98 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments