diff --git a/.github/actions/prepare-tofu/action.yml b/.github/actions/prepare-tofu/action.yml index c64332e3c..09e5f92c7 100644 --- a/.github/actions/prepare-tofu/action.yml +++ b/.github/actions/prepare-tofu/action.yml @@ -2,10 +2,6 @@ name: Prepare OpenTofu Deployment description: Prepares OpenTofu in infra/web. inputs: - opentofu-version: - description: The OpenTofu version to install. - required: false - default: '1.11.5' is_release_tag: description: Whether the build is for a release tag. Passed through to VITE_IS_RELEASE_TAG. required: false @@ -27,22 +23,20 @@ runs: SENTRY_ORG: ${{ env.SENTRY_ORG }} SENTRY_PROJECT: ${{ env.SENTRY_PROJECT }} - - name: Setup OpenTofu - uses: opentofu/setup-opentofu@9d84900f3238fab8cd84ce47d658d25dd008be2f # v1.0.8 - with: - tofu_version: ${{ inputs.opentofu-version }} + - name: Setup OpenTofu via mise + uses: jdx/mise-action@dad1bfd3df957f44999b559dd69dc1671cb4e9ea # v4.2.1 - name: Check formatting shell: bash working-directory: ${{ github.workspace }}/infra/web - run: tofu fmt -check + run: mise run opentofu -- fmt -check - name: Initialize OpenTofu shell: bash working-directory: ${{ github.workspace }}/infra/web - run: tofu init -input=false -reconfigure + run: mise run opentofu -- init -input=false -reconfigure - name: Validate configuration shell: bash working-directory: ${{ github.workspace }}/infra/web - run: tofu validate -no-color + run: mise run opentofu -- validate -no-color diff --git a/.github/actions/setup/action.yml b/.github/actions/setup/action.yml index 9b4c9acbb..961db8d82 100644 --- a/.github/actions/setup/action.yml +++ b/.github/actions/setup/action.yml @@ -18,14 +18,10 @@ inputs: runs: using: composite steps: - - name: Setup pnpm - uses: pnpm/action-setup@b906affcce14559ad1aafd4ab0e942779e9f58b1 # v4.3.0 - - - name: Setup node - uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0 + - name: Setup tools (mise) + uses: jdx/mise-action@dad1bfd3df957f44999b559dd69dc1671cb4e9ea # v4.2.1 with: - node-version-file: '.node-version' - cache: 'pnpm' + cache: true - name: Install dependencies shell: bash diff --git a/.github/workflows/cloudflare-web-deploy.yml b/.github/workflows/cloudflare-web-deploy.yml index 14d65c869..5bba6a672 100644 --- a/.github/workflows/cloudflare-web-deploy.yml +++ b/.github/workflows/cloudflare-web-deploy.yml @@ -55,8 +55,16 @@ jobs: - name: Resolve release version id: version shell: bash + env: + GIT_TAG: ${{ inputs.git_tag }} + REF_NAME: ${{ github.ref_name }} + EVENT_NAME: ${{ github.event_name }} run: | - TAG="${{ github.event_name == 'workflow_dispatch' && inputs.git_tag || github.ref_name }}" + if [[ "$EVENT_NAME" == "workflow_dispatch" && -n "$GIT_TAG" ]]; then + TAG="$GIT_TAG" + else + TAG="$REF_NAME" + fi echo "version=${TAG#v}" >> "$GITHUB_OUTPUT" - name: Prepare OpenTofu deployment @@ -95,8 +103,16 @@ jobs: - name: Resolve release version id: version shell: bash + env: + GIT_TAG: ${{ inputs.git_tag }} + REF_NAME: ${{ github.ref_name }} + EVENT_NAME: ${{ github.event_name }} run: | - TAG="${{ github.event_name == 'workflow_dispatch' && inputs.git_tag || github.ref_name }}" + if [[ "$EVENT_NAME" == "workflow_dispatch" && -n "$GIT_TAG" ]]; then + TAG="$GIT_TAG" + else + TAG="$REF_NAME" + fi echo "version=${TAG#v}" >> "$GITHUB_OUTPUT" - name: Prepare OpenTofu deployment @@ -112,7 +128,7 @@ jobs: SENTRY_PROJECT: ${{ secrets.SENTRY_PROJECT }} - name: Plan infrastructure - run: tofu plan -input=false -no-color + run: mise run opentofu -- plan -input=false -no-color - name: Apply infrastructure - run: tofu apply -input=false -auto-approve + run: mise run opentofu -- apply -input=false -auto-approve diff --git a/.github/workflows/cloudflare-web-dev.yml b/.github/workflows/cloudflare-web-dev.yml index ef2f711a9..e21bf8388 100644 --- a/.github/workflows/cloudflare-web-dev.yml +++ b/.github/workflows/cloudflare-web-dev.yml @@ -62,7 +62,7 @@ jobs: SENTRY_PROJECT: ${{ secrets.SENTRY_PROJECT }} - name: Plan infrastructure - run: tofu plan -input=false -no-color + run: mise run opentofu -- plan -input=false -no-color - name: Apply infrastructure - run: tofu apply -input=false -auto-approve + run: mise run opentofu -- apply -input=false -auto-approve diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index bdb1d0bd5..07e14f503 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -58,6 +58,8 @@ jobs: steps: - name: Checkout repository uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + with: + persist-credentials: false # Add any setup steps before running the `github/codeql-action/init` action. # This includes steps like installing compilers or runtimes (`actions/setup-node` diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index 7b6ed21bc..b52dd86b2 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -49,8 +49,8 @@ jobs: id: release_tag shell: bash run: | - if [[ "${{ github.event_name }}" == "workflow_dispatch" && -n "${{ inputs.git_tag }}" ]]; then - TAG="${{ inputs.git_tag }}" + if [[ "${{ github.event_name }}" == "workflow_dispatch" && -n "${INPUTS_GIT_TAG}" ]]; then + TAG="${INPUTS_GIT_TAG}" else TAG="${GITHUB_REF#refs/tags/}" fi @@ -65,6 +65,8 @@ jobs: echo "value=" >> "$GITHUB_OUTPUT" echo "is_release=false" >> "$GITHUB_OUTPUT" fi + env: + INPUTS_GIT_TAG: ${{ inputs.git_tag }} - name: Extract metadata id: meta diff --git a/.github/workflows/flake-lock-fix.yml b/.github/workflows/flake-lock-fix.yml index c7b844e72..fdf800a84 100644 --- a/.github/workflows/flake-lock-fix.yml +++ b/.github/workflows/flake-lock-fix.yml @@ -42,17 +42,20 @@ jobs: - name: Get GitHub App User ID id: get-user-id - run: echo "user-id=$(gh api "/users/${{ steps.app-token.outputs.app-slug }}[bot]" --jq .id)" >> "$GITHUB_OUTPUT" + run: echo "user-id=$(gh api "/users/${STEPS_APP_TOKEN_OUTPUTS_APP_SLUG}[bot]" --jq .id)" >> "$GITHUB_OUTPUT" env: GH_TOKEN: ${{ steps.app-token.outputs.token }} + STEPS_APP_TOKEN_OUTPUTS_APP_SLUG: ${{ steps.app-token.outputs.app-slug }} - name: Configure bot git identity run: | - git config --global user.name '${{ steps.app-token.outputs.app-slug }}[bot]' - git config --global user.email '${{ steps.get-user-id.outputs.user-id }}+${{ steps.app-token.outputs.app-slug }}[bot]@users.noreply.github.com' + git config --global user.name '${STEPS_APP_TOKEN_OUTPUTS_APP_SLUG}[bot]' + git config --global user.email '${STEPS_GET_USER_ID_OUTPUTS_USER_ID}+${STEPS_APP_TOKEN_OUTPUTS_APP_SLUG}[bot]@users.noreply.github.com' gh auth setup-git env: GH_TOKEN: ${{ steps.app-token.outputs.token }} + STEPS_APP_TOKEN_OUTPUTS_APP_SLUG: ${{ steps.app-token.outputs.app-slug }} + STEPS_GET_USER_ID_OUTPUTS_USER_ID: ${{ steps.get-user-id.outputs.user-id }} - name: Commit and push if changed if: steps.check.outcome == 'failure' diff --git a/.github/workflows/prepare-release.yml b/.github/workflows/prepare-release.yml index 60573416b..29ae03c5d 100644 --- a/.github/workflows/prepare-release.yml +++ b/.github/workflows/prepare-release.yml @@ -20,6 +20,8 @@ jobs: with: app-id: ${{ secrets.APP_ID }} private-key: ${{ secrets.APP_PRIVATE_KEY }} + permission-contents: write + permission-pull-requests: write - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 with: @@ -29,12 +31,8 @@ jobs: - uses: fregante/setup-git-user@024bc0b8e177d7e77203b48dab6fb45666854b35 # v2.0.2 - - uses: knope-dev/action@19617851f9f13ab2f27a05989c55efb18aca3675 # v2.1.2 - with: - version: 0.22.3 - - name: Prepare Release - run: knope prepare-release --verbose + run: mise run knope -- prepare-release --verbose env: GITHUB_TOKEN: ${{ steps.generate-token.outputs.token }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index e6e5f9d7f..6eca8284b 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -20,6 +20,7 @@ jobs: with: app-id: ${{ secrets.APP_ID }} private-key: ${{ secrets.APP_PRIVATE_KEY }} + permission-contents: write - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 with: @@ -27,11 +28,7 @@ jobs: persist-credentials: true token: ${{ steps.generate-token.outputs.token }} - - uses: knope-dev/action@19617851f9f13ab2f27a05989c55efb18aca3675 # v2.1.2 - with: - version: 0.22.3 - - name: Create Release - run: knope release --verbose + run: mise run knope -- release --verbose env: GITHUB_TOKEN: ${{ steps.generate-token.outputs.token }} diff --git a/.github/workflows/rust-quality.yml b/.github/workflows/rust-quality.yml index f7fdd08f0..98679c094 100644 --- a/.github/workflows/rust-quality.yml +++ b/.github/workflows/rust-quality.yml @@ -20,17 +20,19 @@ jobs: runs-on: ubuntu-latest permissions: contents: read + env: + CARGO_INCREMENTAL: 0 + CARGO_TERM_COLOR: always steps: - name: Checkout repository uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 with: persist-credentials: false - - name: Setup Rust - uses: dtolnay/rust-toolchain@2c7215f132e9ebf062739d9130488b56d53c060c # 2c7215f132e9ebf062739d9130488b56d53c060c + - name: Setup mise + uses: jdx/mise-action@dad1bfd3df957f44999b559dd69dc1671cb4e9ea # v4.2.1 with: - toolchain: stable - components: rustfmt + cache: true - name: Check Rust formatting run: cargo fmt --manifest-path src-tauri/Cargo.toml -- --check @@ -40,6 +42,9 @@ jobs: runs-on: ubuntu-22.04 permissions: contents: read + env: + CARGO_INCREMENTAL: 0 + CARGO_TERM_COLOR: always steps: - name: Checkout repository uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 @@ -60,11 +65,10 @@ jobs: libxdo-dev \ pkg-config - - name: Setup Rust - uses: dtolnay/rust-toolchain@2c7215f132e9ebf062739d9130488b56d53c060c # 2c7215f132e9ebf062739d9130488b56d53c060c + - name: Setup mise + uses: jdx/mise-action@dad1bfd3df957f44999b559dd69dc1671cb4e9ea # v4.2.1 with: - toolchain: stable - components: clippy + cache: true - name: Cache Rust build uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1 diff --git a/.github/workflows/tauri-build.yml b/.github/workflows/tauri-build.yml index 9cbb5ae3a..9cb7cdbf2 100644 --- a/.github/workflows/tauri-build.yml +++ b/.github/workflows/tauri-build.yml @@ -120,7 +120,7 @@ jobs: - name: macOS platform: macos-latest asset-platform: macos-universal - rust-targets: aarch64-apple-darwin,x86_64-apple-darwin + rust-targets: aarch64-apple-darwin x86_64-apple-darwin args: --target universal-apple-darwin bundle_path: src-tauri/target/universal-apple-darwin/release/bundle - name: Windows @@ -145,6 +145,8 @@ jobs: SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }} SENTRY_ORG: ${{ secrets.SENTRY_ORG }} SENTRY_PROJECT: ${{ secrets.SENTRY_PROJECT }} + CARGO_INCREMENTAL: 0 + CARGO_TERM_COLOR: always NODE_OPTIONS: --max-old-space-size=8192 TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY }} TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY_PASSWORD }} @@ -178,11 +180,10 @@ jobs: - name: Setup app uses: ./.github/actions/setup - - name: Setup Rust - uses: dtolnay/rust-toolchain@2c7215f132e9ebf062739d9130488b56d53c060c # 2c7215f132e9ebf062739d9130488b56d53c060c - with: - toolchain: stable - targets: ${{ matrix.rust-targets }} + - name: Add Rust targets + if: ${{ matrix.rust-targets != '' }} + shell: bash + run: rustup target add ${{ matrix.rust-targets }} - name: Cache Rust build uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1 @@ -339,7 +340,10 @@ jobs: SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }} SENTRY_ORG: ${{ secrets.SENTRY_ORG }} SENTRY_PROJECT: ${{ secrets.SENTRY_PROJECT }} + CARGO_INCREMENTAL: 0 + CARGO_TERM_COLOR: always NODE_OPTIONS: --max-old-space-size=8192 + RUST_TARGETS: aarch64-linux-android armv7-linux-androideabi i686-linux-android x86_64-linux-android ANDROID_KEY_BASE64: ${{ secrets.ANDROID_KEY_BASE64 }} ANDROID_KEY_ALIAS: ${{ secrets.ANDROID_KEY_ALIAS }} ANDROID_KEY_PASSWORD: ${{ secrets.ANDROID_KEY_PASSWORD }} @@ -362,11 +366,9 @@ jobs: - name: Setup Android SDK uses: android-actions/setup-android@40fd30fb8d7440372e1316f5d1809ec01dcd3699 # v4.0.1 - - name: Setup Rust - uses: dtolnay/rust-toolchain@2c7215f132e9ebf062739d9130488b56d53c060c # 2c7215f132e9ebf062739d9130488b56d53c060c - with: - toolchain: stable - targets: aarch64-linux-android,armv7-linux-androideabi + - name: Add Rust targets + shell: bash + run: rustup target add $RUST_TARGETS - name: Cache Rust build uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1 @@ -453,6 +455,9 @@ jobs: SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }} SENTRY_ORG: ${{ secrets.SENTRY_ORG }} SENTRY_PROJECT: ${{ secrets.SENTRY_PROJECT }} + CARGO_INCREMENTAL: 0 + CARGO_TERM_COLOR: always + RUST_TARGETS: aarch64-apple-ios NODE_OPTIONS: --max-old-space-size=8192 steps: - name: Checkout repository @@ -464,11 +469,9 @@ jobs: - name: Setup app uses: ./.github/actions/setup - - name: Setup Rust - uses: dtolnay/rust-toolchain@2c7215f132e9ebf062739d9130488b56d53c060c # 2c7215f132e9ebf062739d9130488b56d53c060c - with: - toolchain: stable - targets: aarch64-apple-ios + - name: Add Rust targets + shell: bash + run: rustup target add $RUST_TARGETS - name: Cache Rust build uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1 @@ -522,7 +525,8 @@ jobs: shell: bash env: GH_TOKEN: ${{ github.token }} - run: gh release upload "$TAG" "${{ steps.ipa.outputs.path }}" --clobber + STEPS_IPA_OUTPUTS_PATH: ${{ steps.ipa.outputs.path }} + run: gh release upload "$TAG" "${STEPS_IPA_OUTPUTS_PATH}" --clobber - name: Update AltStore/SideStore source shell: bash @@ -531,8 +535,10 @@ jobs: REPO: ${{ github.repository }} ALTSTORE_VERSION: ${{ steps.ipa.outputs.ipa_version }} ALTSTORE_VERSION_BUILD: ${{ steps.ipa.outputs.ipa_build }} + STEPS_IPA_OUTPUTS_NAME: ${{ steps.ipa.outputs.name }} + STEPS_IPA_OUTPUTS_SIZE: ${{ steps.ipa.outputs.size }} run: | - DOWNLOAD_URL="https://github.com/$REPO/releases/download/$TAG/${{ steps.ipa.outputs.name }}" + DOWNLOAD_URL="https://github.com/$REPO/releases/download/$TAG/${STEPS_IPA_OUTPUTS_NAME}" DATE="$(date -u +'%Y-%m-%dT%H:%M:%SZ')" if gh release download "$TAG" --pattern 'altstore-source.json' --dir . --clobber 2>/dev/null; then echo "Using existing altstore-source.json from release $TAG" @@ -540,7 +546,7 @@ jobs: echo "Using repo altstore-source.json" fi node .github/scripts/update-altstore-source.mjs \ - altstore-source.json "${ALTSTORE_VERSION:-$VERSION}" "${ALTSTORE_VERSION_BUILD:-$VERSION}" "${{ steps.ipa.outputs.size }}" "$DOWNLOAD_URL" "$DATE" "Sable $VERSION" + altstore-source.json "${ALTSTORE_VERSION:-$VERSION}" "${ALTSTORE_VERSION_BUILD:-$VERSION}" "${STEPS_IPA_OUTPUTS_SIZE}" "$DOWNLOAD_URL" "$DATE" "Sable $VERSION" gh release upload "$TAG" altstore-source.json --clobber updater-manifest: @@ -572,8 +578,9 @@ jobs: shell: bash env: GH_TOKEN: ${{ github.token }} + NEEDS_SETUP_RELEASE_OUTPUTS_NIGHTLY: ${{ needs.setup-release.outputs.nightly }} run: | - if [ "${{ needs.setup-release.outputs.nightly }}" = "true" ]; then + if [ "${NEEDS_SETUP_RELEASE_OUTPUTS_NIGHTLY}" = "true" ]; then gh release view "$TAG" --json assets \ | jq -r --arg cutoff "$STARTED_AT" \ '.assets[] | select(.updatedAt <= $cutoff and (.name | endswith(".sig"))) | .name' \ diff --git a/.github/zizmor.yml b/.github/zizmor.yml new file mode 100644 index 000000000..191a75c29 --- /dev/null +++ b/.github/zizmor.yml @@ -0,0 +1,4 @@ +rules: + cache-poisoning: + remap: + severity: informational diff --git a/mise.toml b/mise.toml index 3cfa1a944..3d7fafb9d 100644 --- a/mise.toml +++ b/mise.toml @@ -29,7 +29,7 @@ description = "Run all linting, typechecking, formatting, and dead code checks" alias = "l" run = ["tsc", "oxlint .", "oxfmt --check .", "knip"] -[tasks.lint-fix] +[tasks."lint:fix"] description = "Fix lint issues, format, and run typecheck and dead code checks" alias = "lf" run = ["oxlint . --fix", "oxfmt .", "knip --fix"] @@ -40,10 +40,16 @@ alias = "t" run = "vitest" raw = true -[tasks.document-change] +[tasks.knope] +run = "knope" +raw_args = true +hide = true +tools = { "cargo:knope" = "0.23.0", cargo-binstall = "1.20.1" } + +[tasks."knope:document-change"] description = "Document a change with knope" -alias = "doc" -run = "knope document-change" +alias = ["doc", "doc"] +run = { task = "knope", args = ["document-change"] } [tasks."cargo:lint"] description = "Check Rust formatting and lint with Clippy" @@ -51,7 +57,7 @@ alias = ["cl", "cargo-lint"] dir = "src-tauri" run = ["cargo fmt --check", "cargo clippy --all-targets --all-features -- -D warnings"] -[tasks."cargo:lint-fix"] +[tasks."cargo:lint:fix"] description = "Fix Rust formatting and lint issues" alias = ["clf", "cargo-lint-fix"] dir = "src-tauri" @@ -63,3 +69,25 @@ alias = ["ct", "cargo-test"] dir = "src-tauri" run = "cargo test" raw = true + +[tasks."actions:pin"] +description = "Pin GitHub Actions to SHA commit hashes" +run = "pinact run" +tools = { "pinact" = "latest" } + +[tasks."actions:audit"] +description = "Audit GitHub Actions for security issues" +run = "zizmor .github/workflows" +tools = { "zizmor" = "latest" } + +[tasks."actions:update"] +description = "Update pinned GitHub Actions to latest SHAs" +run = "pinact run -u" +tools = { "pinact" = "latest" } + + +[tasks.opentofu] +run = "tofu" +raw_args = true +hide = true +tools = { "opentofu" = "1.11.5" } \ No newline at end of file