internal: rename cli & github crates (#459) #855
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Rust | |
| on: | |
| push: | |
| branches: | |
| - master | |
| tags: | |
| - "**" | |
| pull_request: | |
| jobs: | |
| pre_job: | |
| runs-on: ubuntu-22.04 | |
| outputs: | |
| should_skip: ${{ steps.skip_check.outputs.should_skip }} | |
| paths_result: ${{ steps.skip_check.outputs.paths_result }} | |
| steps: | |
| - id: skip_check | |
| uses: fkirc/skip-duplicate-actions@c449d86cf33a2a6c7a4193264cc2578e2c3266d4 # pin@v4 | |
| with: | |
| paths_ignore: '["docs/**", "*.md"]' | |
| build-linux-x64: | |
| needs: pre_job | |
| if: needs.pre_job.outputs.should_skip != 'true' || startsWith(github.ref, 'refs/tags/') | |
| name: Linux x86_64 | |
| runs-on: ubuntu-22.04 | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Install Toolchain | |
| uses: oxidecomputer/actions-rs_toolchain@ad3f86084a8a5acf2c09cb691421b31cf8af7a36 # pin@oxide/master | |
| with: | |
| toolchain: stable | |
| target: x86_64-unknown-linux-gnu | |
| profile: minimal | |
| override: true | |
| - name: Cache | |
| uses: Swatinem/rust-cache@9d47c6ad4b02e050fd481d890b2ea34778fd09d6 # pin@v2 | |
| - name: Build | |
| run: cargo build --target x86_64-unknown-linux-gnu --release && mv target/x86_64-unknown-linux-gnu/release/squawk target/release/squawk-linux-x64 | |
| - name: Artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: release-squawk-linux-x64 | |
| path: target/release/squawk-linux-x64 | |
| - name: Release | |
| uses: softprops/action-gh-release@de2c0eb89ae2a093876385947365aca7b0e5f844 # pin@v1 | |
| if: startsWith(github.ref, 'refs/tags/') | |
| with: | |
| files: | | |
| target/release/squawk-linux-x64 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| build-linux-arm64: | |
| needs: pre_job | |
| if: needs.pre_job.outputs.should_skip != 'true' || startsWith(github.ref, 'refs/tags/') | |
| name: Linux arm64 | |
| runs-on: ubuntu-22.04 | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Apt | |
| run: sudo apt-get install gcc-aarch64-linux-gnu | |
| - name: Install Toolchain | |
| uses: oxidecomputer/actions-rs_toolchain@ad3f86084a8a5acf2c09cb691421b31cf8af7a36 # pin@oxide/master | |
| with: | |
| toolchain: stable | |
| target: aarch64-unknown-linux-gnu | |
| profile: minimal | |
| override: true | |
| - name: Cache | |
| uses: Swatinem/rust-cache@9d47c6ad4b02e050fd481d890b2ea34778fd09d6 # pin@v2 | |
| - name: Build | |
| run: RUSTFLAGS="-C linker=aarch64-linux-gnu-gcc" cargo build --target aarch64-unknown-linux-gnu --release && mv target/aarch64-unknown-linux-gnu/release/squawk target/release/squawk-linux-arm64 | |
| - name: Artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: release-squawk-linux-arm64 | |
| path: target/release/squawk-linux-arm64 | |
| - name: Release | |
| uses: softprops/action-gh-release@de2c0eb89ae2a093876385947365aca7b0e5f844 # pin@v1 | |
| if: startsWith(github.ref, 'refs/tags/') | |
| with: | |
| files: | | |
| target/release/squawk-linux-arm64 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| build-windows: | |
| needs: pre_job | |
| if: needs.pre_job.outputs.should_skip != 'true' || startsWith(github.ref, 'refs/tags/') | |
| name: Windows | |
| runs-on: windows-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Install Toolchain | |
| uses: oxidecomputer/actions-rs_toolchain@ad3f86084a8a5acf2c09cb691421b31cf8af7a36 # pin@oxide/master | |
| with: | |
| toolchain: stable | |
| target: x86_64-pc-windows-msvc | |
| profile: minimal | |
| override: true | |
| - name: Cache | |
| uses: Swatinem/rust-cache@9d47c6ad4b02e050fd481d890b2ea34778fd09d6 # pin@v2 | |
| - name: Build | |
| run: cargo build --target x86_64-pc-windows-msvc --release && mv target/x86_64-pc-windows-msvc/release/squawk.exe target/release/squawk-windows-x64.exe | |
| - name: Artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: release-squawk-windows-x64.exe | |
| path: target/release/squawk-windows-x64.exe | |
| - name: Release | |
| uses: softprops/action-gh-release@de2c0eb89ae2a093876385947365aca7b0e5f844 # pin@v1 | |
| if: startsWith(github.ref, 'refs/tags/') | |
| with: | |
| files: | | |
| target/release/squawk-windows-x64.exe | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| build-mac: | |
| needs: pre_job | |
| if: needs.pre_job.outputs.should_skip != 'true' || startsWith(github.ref, 'refs/tags/') | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - arch: x64 | |
| target: x86_64-apple-darwin | |
| - arch: arm64 | |
| target: aarch64-apple-darwin | |
| name: macOS ${{ matrix.arch }} | |
| runs-on: macos-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Install Toolchain | |
| uses: oxidecomputer/actions-rs_toolchain@ad3f86084a8a5acf2c09cb691421b31cf8af7a36 # pin@oxide/master | |
| with: | |
| target: ${{ matrix.target }} | |
| profile: minimal | |
| override: true | |
| - name: Cache | |
| uses: Swatinem/rust-cache@9d47c6ad4b02e050fd481d890b2ea34778fd09d6 # pin@v2 | |
| - name: Build for mac | |
| run: cargo build --release --target=${{ matrix.target }} && mv target/${{ matrix.target }}/release/squawk target/release/squawk-darwin-${{ matrix.arch }} | |
| - name: Artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: release-squawk-darwin-${{ matrix.arch }} | |
| path: target/release/squawk-darwin-${{ matrix.arch }} | |
| - name: Release | |
| uses: softprops/action-gh-release@de2c0eb89ae2a093876385947365aca7b0e5f844 # pin@v1 | |
| if: startsWith(github.ref, 'refs/tags/') | |
| with: | |
| files: | | |
| target/release/squawk-darwin-${{ matrix.arch }} | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| publish-npm: | |
| if: startsWith(github.ref, 'refs/tags/') | |
| needs: [build-linux-x64, build-mac, build-windows] | |
| runs-on: ubuntu-22.04 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-node@v3 | |
| with: | |
| node-version: 16 | |
| registry-url: https://registry.npmjs.org/ | |
| - run: npm publish | |
| env: | |
| NODE_AUTH_TOKEN: ${{secrets.npm_token}} | |
| publish-docker: | |
| if: startsWith(github.ref, 'refs/tags/') | |
| needs: [build-linux-x64, build-mac, build-windows] | |
| runs-on: ubuntu-22.04 | |
| permissions: | |
| contents: read | |
| packages: write | |
| attestations: write | |
| id-token: write | |
| env: | |
| REGISTRY: ghcr.io | |
| IMAGE_NAME: ${{ github.repository }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Log in to the Container registry | |
| uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1 | |
| with: | |
| registry: ${{ env.REGISTRY }} | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Extract metadata for Docker | |
| id: meta | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | |
| tags: | | |
| type=semver,pattern={{version}} | |
| type=semver,pattern={{major}}.{{minor}} | |
| type=semver,pattern={{major}} | |
| type=raw,value=latest | |
| type=ref,event=branch | |
| type=sha | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Build and push Docker image | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: . | |
| push: true | |
| tags: ${{ steps.meta.outputs.tags }} | |
| labels: ${{ steps.meta.outputs.labels }} | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| deploy-playground: | |
| if: startsWith(github.ref, 'refs/tags/') | |
| runs-on: ubuntu-22.04 | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Cache | |
| uses: Swatinem/rust-cache@9d47c6ad4b02e050fd481d890b2ea34778fd09d6 # pin@v2 | |
| - name: Install wasm-pack | |
| run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh | |
| - uses: pnpm/action-setup@v2 | |
| with: | |
| version: 8 | |
| - uses: actions/setup-node@v3 | |
| with: | |
| node-version-file: "playground/package.json" | |
| cache-dependency-path: "playground/pnpm-lock.yaml" | |
| cache: "pnpm" | |
| - name: Install JS dependencies | |
| working-directory: "playground" | |
| run: pnpm install | |
| - name: Build | |
| working-directory: "playground" | |
| run: pnpm build | |
| - name: Deploy to Netlify | |
| uses: nwtgck/actions-netlify@v2 | |
| with: | |
| publish-dir: "playground/dist" | |
| production-branch: main | |
| github-token: ${{ secrets.GITHUB_TOKEN }} | |
| deploy-message: "Deploy from GitHub Actions" | |
| fails-without-credentials: true | |
| enable-pull-request-comment: false | |
| enable-commit-comment: false | |
| env: | |
| NETLIFY_AUTH_TOKEN: ${{ secrets.PLAYGROUND_NETLIFY_AUTH_TOKEN }} | |
| NETLIFY_SITE_ID: ${{ secrets.PLAYGROUND_NETLIFY_SITE_ID }} | |
| lint: | |
| needs: pre_job | |
| if: needs.pre_job.outputs.should_skip != 'true' | |
| runs-on: ubuntu-22.04 | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Install Toolchain | |
| uses: oxidecomputer/actions-rs_toolchain@ad3f86084a8a5acf2c09cb691421b31cf8af7a36 # pin@oxide/master | |
| - name: Cache | |
| uses: Swatinem/rust-cache@9d47c6ad4b02e050fd481d890b2ea34778fd09d6 # pin@v2 | |
| - name: Install Rust Fmt | |
| run: rustup component add rustfmt | |
| - name: Install Clippy | |
| run: rustup component add clippy | |
| - name: Get Clippy Version | |
| run: cargo clippy --version | |
| - name: Lint | |
| run: ./s/lint | |
| test: | |
| needs: pre_job | |
| if: needs.pre_job.outputs.should_skip != 'true' | |
| runs-on: ubuntu-22.04 | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Install Toolchain | |
| uses: oxidecomputer/actions-rs_toolchain@ad3f86084a8a5acf2c09cb691421b31cf8af7a36 # pin@oxide/master | |
| - name: Cache | |
| uses: Swatinem/rust-cache@9d47c6ad4b02e050fd481d890b2ea34778fd09d6 # pin@v2 | |
| - name: Test | |
| run: ./s/test | |
| check_version: | |
| runs-on: ubuntu-22.04 | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - uses: actions/setup-python@v4 | |
| with: | |
| python-version-file: ".python-version" | |
| - name: Check versions are consistent | |
| run: ./s/check-version |