Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

github: scope/narrow permissions, prevent template injection via GHA, enable zizmor workflow #5076

Draft
wants to merge 10 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .github/workflows/build-binaries.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
branches:
- main

permissions: read-all
permissions: {}

jobs:
binaries:
Expand Down Expand Up @@ -42,6 +42,8 @@ jobs:
name: Build binary artifacts
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
with:
persist-credentials: false
- name: Install packages (Ubuntu)
if: matrix.os == 'ubuntu-24.04'
run: |
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/build-nix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

permissions: read-all
permissions: {}

jobs:
nix:
Expand All @@ -26,6 +26,7 @@ jobs:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
with:
fetch-depth: 0
persist-credentials: false
- uses: DeterminateSystems/nix-installer-action@e50d5f73bfe71c2dd0aa4218de8f4afa59f8f81d
- uses: DeterminateSystems/magic-nix-cache-action@87b14cf437d03d37989d87f0fa5ce4f5dc1a330b
- run: nix flake check -L --show-trace
18 changes: 17 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

permissions: read-all
permissions: {}

env:
CARGO_INCREMENTAL: 0
Expand Down Expand Up @@ -41,6 +41,8 @@ jobs:

steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
with:
persist-credentials: false

# The default version of gpg installed on the runners is a version baked in with git
# which only contains the components needed by git and doesn't work for our test cases.
Expand Down Expand Up @@ -85,6 +87,8 @@ jobs:

steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
with:
persist-credentials: false

- name: Install Rust
uses: dtolnay/rust-toolchain@a54c7afa936fefeb4456b2dd8068152669aa8203
Expand All @@ -98,6 +102,8 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
with:
persist-credentials: false
- uses: dtolnay/rust-toolchain@a54c7afa936fefeb4456b2dd8068152669aa8203
with:
toolchain: stable
Expand All @@ -112,6 +118,8 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
with:
persist-credentials: false
- uses: dtolnay/rust-toolchain@a54c7afa936fefeb4456b2dd8068152669aa8203
with:
toolchain: nightly
Expand All @@ -123,6 +131,8 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
with:
persist-credentials: false
- uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b
with:
python-version: 3.11
Expand All @@ -141,6 +151,8 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
with:
persist-credentials: false
- name: Install uv
uses: astral-sh/setup-uv@887a942a15af3a7626099df99e897a18d9e5ab3a
# 'only-managed' means that uv will always download Python, even
Expand All @@ -161,6 +173,8 @@ jobs:

steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
with:
persist-credentials: false
- uses: EmbarkStudios/cargo-deny-action@e2f4ede4a4e60ea15ff31bc0647485d80c66cfba
with:
command: check ${{ matrix.checks }}
Expand All @@ -172,6 +186,8 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
with:
persist-credentials: false
- uses: dtolnay/rust-toolchain@a54c7afa936fefeb4456b2dd8068152669aa8203
with:
toolchain: stable
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/codespell.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,16 @@ concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

permissions: read-all
permissions: {}

jobs:
codespell:
name: Codespell
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
with:
persist-credentials: false
- uses: codespell-project/actions-codespell@406322ec52dd7b488e48c1c4b82e2a8b3a1bf630
with:
check_filenames: true
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

permissions: read-all
permissions: {}

jobs:
dependabot-auto-merge:
Expand Down
7 changes: 5 additions & 2 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ on:
branches:
- main

permissions:
contents: write
permissions: {}

jobs:
prerelease-docs-build-deploy:
Expand All @@ -18,6 +17,8 @@ jobs:

steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
with:
persist-credentials: false
- run: "git fetch origin gh-pages --depth=1"
- uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b
with:
Expand All @@ -27,6 +28,8 @@ jobs:
with:
version: "0.5.1"
- name: Install dependencies, compile and deploy docs
permissions:
contents: write
run: |
git config user.name 'jj-docs[bot]'
git config user.email 'jj-docs[bot]@users.noreply.github.io'
Expand Down
154 changes: 85 additions & 69 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
release:
types: [published]

permissions: read-all
permissions: {}

env:
CARGO_INCREMENTAL: 0
Expand All @@ -17,74 +17,83 @@ jobs:
strategy:
fail-fast: false
matrix:
build: [linux-x86_64-musl, linux-aarch64-musl, macos-x86_64, macos-aarch64, win-msvc]
build: [
linux-x86_64-musl,
linux-aarch64-musl,
macos-x86_64,
macos-aarch64,
win-msvc,
]
include:
- build: linux-x86_64-musl
os: ubuntu-24.04
target: x86_64-unknown-linux-musl
- build: linux-aarch64-musl
os: ubuntu-24.04
target: aarch64-unknown-linux-musl
- build: macos-x86_64
os: macos-13
target: x86_64-apple-darwin
- build: macos-aarch64
os: macos-14
target: aarch64-apple-darwin
- build: win-msvc
os: windows-2022
target: x86_64-pc-windows-msvc
- build: linux-x86_64-musl
os: ubuntu-24.04
target: x86_64-unknown-linux-musl
- build: linux-aarch64-musl
os: ubuntu-24.04
target: aarch64-unknown-linux-musl
- build: macos-x86_64
os: macos-13
target: x86_64-apple-darwin
- build: macos-aarch64
os: macos-14
target: aarch64-apple-darwin
- build: win-msvc
os: windows-2022
target: x86_64-pc-windows-msvc
runs-on: ${{ matrix.os }}
steps:
- name: Checkout repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
- name: Install packages (Ubuntu)
if: matrix.os == 'ubuntu-24.04'
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends xz-utils liblz4-tool musl-tools
- name: Install Rust
uses: dtolnay/rust-toolchain@a54c7afa936fefeb4456b2dd8068152669aa8203
with:
toolchain: stable
target: ${{ matrix.target }}
- name: Download cross-compilation tool (linux-aarch64)
if: matrix.target == 'aarch64-unknown-linux-musl'
run: wget -c https://github.com/cross-rs/cross/releases/download/v0.2.5/cross-x86_64-unknown-linux-gnu.tar.gz -O - | tar -xz
- name: Build release binary
shell: bash
run: |
CARGO_CMD=cargo
if [ "${{ matrix.target }}" = "aarch64-unknown-linux-musl" ]; then
CARGO_CMD=$PWD/cross
fi
$CARGO_CMD build --target ${{ matrix.target }} --verbose --release --features packaging,vendored-openssl
- name: Build archive
shell: bash
run: |
outdir="target/${{ matrix.target }}/release"
staging="jj-${{ github.event.release.tag_name }}-${{ matrix.target }}"
mkdir "$staging"
cp {README.md,LICENSE} "$staging/"
if [ "${{ matrix.os }}" = "windows-2022" ]; then
cp "$outdir/jj.exe" "$staging/"
cd "$staging"
7z a "../$staging.zip" .
echo "ASSET=$staging.zip" >> $GITHUB_ENV
else
cp "$outdir/jj" "$staging/"
tar czf "$staging.tar.gz" -C "$staging" .
echo "ASSET=$staging.tar.gz" >> $GITHUB_ENV
fi
- name: Upload release archive
uses: actions/upload-release-asset@e8f9f06c4b078e705bd2ea027f0926603fc9b4d5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: ${{ env.ASSET }}
asset_name: ${{ env.ASSET }}
asset_content_type: application/octet-stream
- name: Checkout repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
with:
persist-credentials: false
- name: Install packages (Ubuntu)
if: matrix.os == 'ubuntu-24.04'
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends xz-utils liblz4-tool musl-tools
- name: Install Rust
uses: dtolnay/rust-toolchain@a54c7afa936fefeb4456b2dd8068152669aa8203
with:
toolchain: stable
target: ${{ matrix.target }}
- name: Download cross-compilation tool (linux-aarch64)
if: matrix.target == 'aarch64-unknown-linux-musl'
run: wget -c https://github.com/cross-rs/cross/releases/download/v0.2.5/cross-x86_64-unknown-linux-gnu.tar.gz -O - | tar -xz
- name: Build release binary
shell: bash
run: |
CARGO_CMD=cargo
if [ "${{ matrix.target }}" = "aarch64-unknown-linux-musl" ]; then
CARGO_CMD=$PWD/cross
fi
$CARGO_CMD build --target ${{ matrix.target }} --verbose --release --features packaging,vendored-openssl
- name: Build archive
shell: bash
run: |
outdir="target/${{ matrix.target }}/release"
staging="jj-${RELEASE_TAG_NAME}-${{ matrix.target }}"
mkdir "$staging"
cp {README.md,LICENSE} "$staging/"
if [ "${{ matrix.os }}" = "windows-2022" ]; then
cp "$outdir/jj.exe" "$staging/"
cd "$staging"
7z a "../$staging.zip" .
echo "ASSET=$staging.zip" >> $GITHUB_ENV
else
cp "$outdir/jj" "$staging/"
tar czf "$staging.tar.gz" -C "$staging" .
echo "ASSET=$staging.tar.gz" >> $GITHUB_ENV
fi
- name: Upload release archive
uses: actions/upload-release-asset@e8f9f06c4b078e705bd2ea027f0926603fc9b4d5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
RELEASE_TAG_NAME: ${{ github.event.release.tag_name }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: ${{ env.ASSET }}
asset_name: ${{ env.ASSET }}
asset_content_type: application/octet-stream

docs-release-archive:
runs-on: ubuntu-latest
Expand All @@ -97,6 +106,8 @@ jobs:
sudo apt-get update
sudo apt-get install -y --no-install-recommends xz-utils liblz4-tool musl-tools
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
with:
persist-credentials: false
- uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b
with:
python-version: 3.11
Expand All @@ -107,13 +118,14 @@ jobs:
- name: Compile docs and zip them up
run: |
uv run -- mkdocs build -f mkdocs-offline.yml
archive="jj-${{ github.event.release.tag_name }}-docs-html.tar.gz"
archive="jj-${RELEASE_TAG_NAME}-docs-html.tar.gz"
tar czf "$archive" -C "rendered-docs" .
echo "ASSET=$archive" >> $GITHUB_ENV
- name: Upload release archive
uses: actions/upload-release-asset@e8f9f06c4b078e705bd2ea027f0926603fc9b4d5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
RELEASE_TAG_NAME: ${{ github.event.release.tag_name }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: ${{ env.ASSET }}
Expand All @@ -127,7 +139,9 @@ jobs:

steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
- run: "git fetch origin gh-pages --depth=1"
with:
persist-credentials: false
- run: "git fetch origin gh-pages --depth=1"
- uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b
with:
python-version: 3.11
Expand All @@ -141,6 +155,8 @@ jobs:
git config user.email 'jj-docs[bot]@users.noreply.github.io'
# Using the 'latest' tag below makes the website default
# to this version.
.github/scripts/docs-build-deploy 'https://jj-vcs.github.io/jj' "${{ github.event.release.tag_name }}" latest --update-aliases --push
.github/scripts/docs-build-deploy 'https://jj-vcs.github.io/jj' "${RELEASE_TAG_NAME}" latest --update-aliases --push
env:
RELEASE_TAG_NAME: ${{ github.event.release.tag_name }}
- name: "Show `git diff --stat`"
run: git diff --stat gh-pages^ gh-pages || echo "(No diffs)"
Loading
Loading