Release 0.0.1-beta.4 #311
This file contains 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: CI + CD | |
on: | |
pull_request: | |
push: | |
branches: | |
- main | |
workflow_dispatch: | |
# Make sure CI fails on all warnings, including Clippy lints | |
env: | |
RUSTFLAGS: "-Dwarnings" | |
jobs: | |
lint: # Also checks formatting. | |
name: Run lint | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Setup env | |
uses: ./.github/actions/setup-env | |
with: | |
rust_cache_key: cargo | |
rust_components: clippy, rustfmt | |
- uses: actions/cache@v3 | |
with: | |
path: | | |
~/.cache/pre-commit | |
key: | |
${{ runner.os }}-pre-commit-${{ | |
hashFiles('**/.pre-commit-config.yaml') }} | |
- name: Run lint | |
run: | | |
just pre-commit | |
just lint | |
unit: | |
name: Run unit test | |
strategy: | |
matrix: | |
os: | |
- ubuntu-latest | |
- macos-latest | |
runs-on: ${{ matrix.os }} | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Setup env | |
uses: ./.github/actions/setup-env | |
with: | |
rust_cache_key: cargo | |
- name: Run unit test | |
run: just test | |
build: | |
name: Build release | |
needs: | |
- lint | |
- unit | |
strategy: | |
matrix: | |
build: | |
- linux | |
- macos | |
include: | |
- build: linux | |
os: ubuntu-latest | |
target: x86_64-unknown-linux-musl | |
- build: macos | |
os: macos-latest | |
target: x86_64-apple-darwin | |
runs-on: ${{ matrix.os }} | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Setup env | |
uses: ./.github/actions/setup-env | |
with: | |
rust_cache_key: cross | |
rust_target: ${{ matrix.target }} | |
- name: Build release | |
run: | | |
just get-cross | |
just cross ${{ matrix.target }} | |
- name: Upload binary artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: pls-${{ matrix.target }} | |
path: target/${{ matrix.target }}/release/pls | |
docs: | |
name: Publish docs | |
runs-on: ubuntu-latest | |
# Do not run this job on pull requests. | |
if: github.event_name == 'push' | |
needs: | |
- build | |
permissions: | |
pages: write # to deploy to GitHub Pages | |
id-token: write # to verify the deployment originates from an appropriate source | |
environment: | |
name: github-pages | |
url: ${{ steps.deployment.outputs.page_url }} | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Setup env | |
uses: ./.github/actions/setup-env | |
with: | |
rust_cache_key: docs | |
- name: Download artifact | |
uses: actions/download-artifact@v4 | |
with: | |
name: pls-x86_64-unknown-linux-musl | |
path: /tmp/pls | |
- name: Make binary accessible and executable | |
run: | | |
chmod +x /tmp/pls/pls | |
echo "/tmp/pls" >> $GITHUB_PATH | |
# This must be a separate step because `$PATH` changes are not reflected | |
# immediately. | |
- name: Ensure binary is accessible | |
run: pls --version | |
- name: Setup Python | |
uses: actions/setup-python@v3 | |
with: | |
python-version: 3.11 | |
- name: Setup Poetry | |
uses: snok/install-poetry@v1 | |
with: | |
virtualenvs-in-project: true | |
- name: Setup pnpm | |
uses: pnpm/action-setup@v2 | |
with: | |
version: 8 | |
- name: Setup Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 18.x | |
cache: pnpm | |
cache-dependency-path: docs/pnpm-lock.yaml | |
- name: Install all dependencies | |
run: just install | |
- name: Generate examples | |
working-directory: examples/ | |
run: just all | |
- name: Build and publish docs | |
if: | | |
github.event_name == 'push' || | |
github.event_name == 'workflow_dispatch' | |
working-directory: docs/ | |
run: | | |
pnpm build | |
cd dist | |
git init --initial-branch=gh-pages | |
git config user.name "Dhruv Bhanushali" | |
git config user.email "hi@dhruvkb.dev" | |
touch .nojekyll | |
echo "pls.cli.rs" > CNAME | |
git add . | |
git commit --all --message "Build documentation" | |
git remote add origin https://x-access-token:${{ secrets.ACCESS_TOKEN }}@github.com/pls-rs/pls-rs.github.io.git | |
git push --force origin gh-pages |