diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 0000000..5b7f4ea --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1 @@ +ko_fi: ameknite diff --git a/.github/dependabot.yaml b/.github/dependabot.yaml new file mode 100644 index 0000000..09f4923 --- /dev/null +++ b/.github/dependabot.yaml @@ -0,0 +1,34 @@ +version: 2 + +updates: + - package-ecosystem: cargo + directory: / + schedule: + interval: weekly + allow: + - dependency-type: all + groups: + patch-updates: + patterns: + - "*" + update-types: + - "patch" + minor-updates: + patterns: + - "*" + update-types: + - "minor" + major-updates: + patterns: + - "*" + update-types: + - "major" + + - package-ecosystem: github-actions + directory: / + schedule: + interval: weekly + groups: + github-actions-updates: + patterns: + - "*" diff --git a/.github/workflows/add_notice.yaml b/.github/workflows/add_notice.yaml new file mode 100644 index 0000000..7b83152 --- /dev/null +++ b/.github/workflows/add_notice.yaml @@ -0,0 +1,87 @@ +name: Add Notice + +permissions: + contents: write + +on: + workflow_call: + inputs: + message: + type: string + description: Replace notice with this message + notice_path: + type: string + description: Path to the notice file + extensions: + type: string + description: Apply notice by extensions, e.g. rs,js,kt. + comment_styles: + type: string + description: Comment Styles, e.g. //,#,// + commit_message: + type: string + workflow_dispatch: + inputs: + message: + type: string + description: Replace notice with this message + notice_path: + type: string + description: Path to the notice file + extensions: + type: string + description: Apply notice by extensions, e.g. rs,js,kt. + comment_styles: + type: string + description: Comment Styles, e.g. //,#,// + +jobs: + check-notice-existence: + runs-on: ubuntu-latest + steps: + - name: Fetch Repository + uses: actions/checkout@v4 + + - name: "Check file existence" + id: check-files + uses: andstor/file-existence-action@v3 + with: + files: ${{ inputs.notice_path || './NOTICE' }} + + - name: print if skip add-notice + if: steps.check-files.outputs.files_exists + run: echo "add-notice needs a ${{ inputs.notice_path || './NOTICE'}} file" + + outputs: + notice_exist: ${{ steps.check-files.outputs.files_exists }} + + add-notice: + needs: check-notice-existence + if: ${{ needs.check-notice-existence.outputs.notice_exist == 'true'}} + runs-on: ubuntu-latest + steps: + - name: Fetch Repository + uses: actions/checkout@v4 + + - run: git pull + + - name: Install stable toolchain + uses: actions-rust-lang/setup-rust-toolchain@v1 + + - name: Install add-notice + uses: taiki-e/install-action@v2 + with: + tool: add-notice + + - name: Run add-notice + if: ${{ inputs.message == '' }} + run: add-notice --notice ${{ inputs.notice_path || './NOTICE' }} -e ${{ inputs.extensions || 'rs' }} -c ${{ inputs.comment_styles || '//' }} + + - name: Replace notice + if: ${{ inputs.message }} + run: add-notice --notice ${{ inputs.notice_path || './NOTICE' }} --replace-with-string ${{ inputs.message }} -e ${{ inputs.extensions || 'rs' }} -c ${{ inputs.comment_styles || '//' }} + + - name: Commit and Push + uses: stefanzweifel/git-auto-commit-action@v5 + with: + commit_message: "[${{ inputs.commit_message || 'Manual run' }}] Add Notice to New Files" diff --git a/.github/workflows/auto_merge.yaml b/.github/workflows/auto_merge.yaml new file mode 100644 index 0000000..0d1e89e --- /dev/null +++ b/.github/workflows/auto_merge.yaml @@ -0,0 +1,25 @@ +name: Auto Merge Dependabot + +on: + pull_request: + workflow_dispatch: + +permissions: + contents: write + pull-requests: write + +jobs: + dependabot: + runs-on: ubuntu-latest + if: github.actor == 'dependabot[bot]' + steps: + - name: Dependabot metadata + id: metadata + uses: dependabot/fetch-metadata@v1 + with: + github-token: "${{ secrets.GITHUB_TOKEN }}" + - name: Enable auto-merge for Dependabot PRs + run: gh pr merge --auto --merge "$PR_URL" + env: + PR_URL: ${{github.event.pull_request.html_url}} + GH_TOKEN: ${{secrets.GITHUB_TOKEN}} diff --git a/.github/workflows/build_and_release.yaml b/.github/workflows/build_and_release.yaml new file mode 100644 index 0000000..b51750f --- /dev/null +++ b/.github/workflows/build_and_release.yaml @@ -0,0 +1,230 @@ +name: "[MAIN] Build & Release" + +permissions: + # To upload files to GitHub Releases + contents: write + +on: + workflow_dispatch: + inputs: + version: + type: string + description: "Version: (e.g. -> v3.1.4-alpha+159)" + release_type: + type: choice + default: none + options: + - none + - patch + - minor + - major + update-msrv: + type: boolean + +jobs: + validate-input: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - uses: actions-ecosystem/action-regex-match@v2 + id: regex-match + with: + text: ${{ inputs.version }} + regex: '^v(\d+)\.(\d+)\.(\d+)-?(\w*)\+?(\d*)$' + + - name: Fail if don't match regex + if: ${{ inputs.version && steps.regex-match.outputs.match == '' }} + run: | + echo "${{inputs.version}} doesn't match regex. Use a version similar to v3.1.4-alpha+159" + exit 1; + + get-version: + needs: validate-input + runs-on: ubuntu-latest + steps: + - name: Fetch Repository + uses: actions/checkout@v4 + + - name: Install jql + if: ${{ !inputs.version }} + uses: taiki-e/install-action@v2 + with: + tool: jql + + - name: Install cargo-bump + if: ${{ !inputs.version }} + uses: taiki-e/install-action@v2 + with: + tool: cargo-bump + + - name: Current versions with None + id: current_version + if: ${{ !inputs.version && inputs.release_type == 'none' }} + run: | + version=$(cargo metadata --format-version=1 --no-deps | jql '"packages"|>"version"<|[0]' --raw-string); + echo $version; + echo "current_version=$version" >> "$GITHUB_OUTPUT"; + normal_version=v$version + echo $normal_version; + echo "normal_tag_version=$normal_version" >> "$GITHUB_OUTPUT"; + + - name: New versions using release_type + id: new_version + if: ${{ !inputs.version && inputs.release_type != 'none' }} + run: | + cargo bump ${{ inputs.release_type }}; + version=$(cargo metadata --format-version=1 --no-deps | jql '"packages"|>"version"<|[0]' --raw-string); + echo $version; + echo "new_version=$version" >> "$GITHUB_OUTPUT"; + normal_version=v$version + echo $normal_version; + echo "normal_tag_version=$normal_version" >> "$GITHUB_OUTPUT"; + + - name: Versions using tag + id: full_version + if: inputs.version + run: | + tag=${{inputs.version}}; + echo $tag; + echo "normal_crate_version=${tag##v} >> GITHUB_OUTPUT"; + echo ${tag##v}; + + outputs: + tag_version: ${{ inputs.version || steps.new_version.outputs.normal_tag_version || steps.current_version.outputs.normal_tag_version }} + crate_version: ${{ steps.full_version.outputs.normal_crate_version || steps.new_version.outputs.new_version || steps.current_version.outputs.current_version }} + + pre-release: + needs: get-version + uses: ./.github/workflows/pre_release.yaml + with: + version: ${{ needs.get-version.outputs.crate_version }} + update-msrv: ${{ inputs.update-msrv }} + + create-tag: + needs: [get-version, pre-release] + runs-on: ubuntu-latest + steps: + - name: Fetch Repository + uses: actions/checkout@v4 + + - run: git pull + + - uses: mukunku/tag-exists-action@v1.6.0 + id: check-tag + with: + tag: ${{ needs.get-version.outputs.tag_version }} + + - name: Create tag + if: steps.check-tag.outputs.exists == 'false' + run: | + git config user.name github-actions + git config user.email github-actions@github.com + git tag ${{ needs.get-version.outputs.tag_version }} + git push origin ${{ needs.get-version.outputs.tag_version }} + + create-release: + needs: [get-version, create-tag] + runs-on: ubuntu-latest + steps: + - name: Fetch Repository + uses: actions/checkout@v4 + + - uses: taiki-e/create-gh-release-action@v1 + with: + token: ${{ secrets.GITHUB_TOKEN }} + changelog: CHANGELOG.md + allow-missing-changelog: true + ref: refs/tags/${{ needs.get-version.outputs.tag_version }} + + check-if-bin: + runs-on: ubuntu-latest + steps: + - name: Fetch Repository + uses: actions/checkout@v4 + + - name: Install stable toolchain + uses: actions-rust-lang/setup-rust-toolchain@v1 + + - name: Install jql + uses: taiki-e/install-action@v2 + with: + tool: jql + + - name: Searching for bin + id: searching + run: | + result=$(cargo metadata --format-version=1 --no-deps | jql '"packages"|>"targets"<|[0]|>"kind"' | jql '..' -i); + echo "targets=$result" >> "$GITHUB_OUTPUT"; + echo kind of targets $result; + + - name: print if skip upploading binaries to github release + if: ${{ !contains(steps.searching.outputs.targets, 'bin') }} + run: echo "This job avoid publishing binaries to github releases for libraries crates" + + outputs: + is_bin: ${{ contains(steps.searching.outputs.targets, 'bin') }} + + build-and-release: + needs: [get-version, create-release, check-if-bin] + if: ${{ needs.check-if-bin.outputs.is_bin == 'true' }} + name: ${{ matrix.target }} (${{ matrix.os }}) + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + include: + - {os: ubuntu-latest, target: x86_64-unknown-linux-gnu, cross: false} + - {os: ubuntu-latest, target: x86_64-unknown-linux-musl, cross: true} + - {os: ubuntu-latest, target: aarch64-unknown-linux-gnu, cross: true} + - {os: ubuntu-latest, target: aarch64-unknown-linux-musl, cross: true} + + - {os: windows-latest, target: x86_64-pc-windows-msvc, cross: false} + - {os: windows-latest, target: x86_64-pc-windows-gnu, cross: true} + - {os: windows-latest, target: aarch64-pc-windows-msvc, cross: false} + + - {os: macos-latest, target: x86_64-apple-darwin, cross: false} + - {os: macos-latest, target: aarch64-apple-darwin, cross: false} + steps: + - name: Fetch Repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Get sha-commit from tag + id: get_baseline_sha + shell: bash + run: | + latest_sha=$(git rev-list --tags --max-count=1) + echo "sha_tag=$latest_sha" >> "$GITHUB_OUTPUT"; + + - name: Checkout source code to specific tag + uses: actions/checkout@v4 + with: + ref: ${{ steps.get_baseline_sha.outputs.sha_tag }} + + - name: Install stable toolchain + uses: actions-rust-lang/setup-rust-toolchain@v1 + with: + target: ${{ matrix.target }} + + - name: Install cross-compilation tools + if: ${{ matrix.cross }} == 'true' + uses: taiki-e/setup-cross-toolchain-action@v1 + with: + target: ${{ matrix.target }} + + - uses: taiki-e/upload-rust-binary-action@v1 + with: + bin: ${{ github.event.repository.name }} + target: ${{ matrix.target }} + include: attribution + archive: $bin-$tag-$target + token: ${{ secrets.GITHUB_TOKEN }} + ref: refs/tags/${{ needs.get-version.outputs.tag_version }} + checksum: sha256 + + publish-crate: + needs: [create-tag] + uses: ./.github/workflows/publish.yaml + secrets: inherit diff --git a/.github/workflows/bump_version.yaml b/.github/workflows/bump_version.yaml new file mode 100644 index 0000000..3107c03 --- /dev/null +++ b/.github/workflows/bump_version.yaml @@ -0,0 +1,41 @@ +name: Bump Version + +on: + workflow_call: + inputs: + crate-version: + type: string + required: true + workflow_dispatch: + inputs: + crate-version: + description: "Bump version: (e.g. -> 3.1.4-alpha+159)" + required: true + type: string + +jobs: + bump-version: + runs-on: ubuntu-latest + steps: + - name: Fetch Repository + uses: actions/checkout@v4 + + - name: Install stable toolchain + uses: actions-rust-lang/setup-rust-toolchain@v1 + + - uses: actions/checkout@v4 + + - run: git pull + + - name: Install cargo-bump + uses: taiki-e/install-action@v2 + with: + tool: cargo-bump + + - name: Run cargo bump + run: cargo bump ${{ inputs.crate-version }} + + - name: Commit and Push + uses: stefanzweifel/git-auto-commit-action@v5 + with: + commit_message: "Bump version: ${{ inputs.crate-version }}" diff --git a/.github/workflows/cache.yaml b/.github/workflows/cache.yaml new file mode 100644 index 0000000..8275c98 --- /dev/null +++ b/.github/workflows/cache.yaml @@ -0,0 +1,16 @@ +name: Clean Cache + +permissions: + actions: write + +on: + workflow_dispatch: + +jobs: + clean-cache: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - run: gh cache delete --all + env: + GH_TOKEN: ${{ github.token }} diff --git a/.github/workflows/cargo_deny.yaml b/.github/workflows/cargo_deny.yaml new file mode 100644 index 0000000..0e1c991 --- /dev/null +++ b/.github/workflows/cargo_deny.yaml @@ -0,0 +1,35 @@ +# Check for licenses and advisores +# ../../deny.toml +name: Cargo deny + +on: + workflow_call: + workflow_dispatch: + +jobs: + cargo-deny: + runs-on: ubuntu-latest + steps: + - name: Fetch Repository + uses: actions/checkout@v4 + + - name: Install stable toolchain + uses: actions-rust-lang/setup-rust-toolchain@v1 + + - name: Cargo deny + uses: EmbarkStudios/cargo-deny-action@v1 + + cargo-audit: + runs-on: ubuntu-latest + steps: + - name: Fetch Repository + uses: actions/checkout@v4 + + - name: Install stable toolchain + uses: actions-rust-lang/setup-rust-toolchain@v1 + + - uses: taiki-e/install-action@v2 + with: + tool: cargo-audit + + - run: cargo audit diff --git a/.github/workflows/cargo_semver_checks.yaml b/.github/workflows/cargo_semver_checks.yaml new file mode 100644 index 0000000..17afd06 --- /dev/null +++ b/.github/workflows/cargo_semver_checks.yaml @@ -0,0 +1,102 @@ +name: Cargo Semver Checks + +on: + workflow_call: + inputs: + bump-version: + type: string + required: true + workflow_dispatch: + inputs: + bump-version: + description: "Bump version: (e.g. -> 3.6.1)" + type: string + release_type: + type: choice + default: none + options: + - none + - patch + - minor + - major + +jobs: + check-if-lib: + runs-on: ubuntu-latest + steps: + - name: Fetch Repository + uses: actions/checkout@v4 + + - name: Install stable toolchain + uses: actions-rust-lang/setup-rust-toolchain@v1 + + - name: Install jql + uses: taiki-e/install-action@v2 + with: + tool: jql + + - name: Searching for lib + id: searching + run: | + result=$(cargo metadata --format-version=1 --no-deps | jql '"packages"|>"targets"<|[0]|>"kind"' | jql '..' -i); + echo "targets=$result" >> "$GITHUB_OUTPUT"; + echo kind of targets $result; + + - name: print if skip cargo-semver-checks + if: ${{ !contains(steps.searching.outputs.targets, 'lib') }} + run: echo "cargo semver-check only works in libraries" + + outputs: + is_lib: ${{ contains(steps.searching.outputs.targets, 'lib') }} + + get-baseline: + runs-on: ubuntu-latest + steps: + - name: Fetch Repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Get latest sha-commit from previous tag + id: get_baseline_sha + run: | + latest_sha=$(git rev-list --tags --max-count=1) + echo $latest_sha + echo "baseline=$latest_sha" >> "$GITHUB_OUTPUT"; + + - name: print if skip cargo-semver-checks + if: ${{ steps.get_baseline_sha.outputs.baseline == '' }} + run: echo "semver-checks needs a baseline. The baseline is the latest commit of the previous tag" + outputs: + baseline: ${{ steps.get_baseline_sha.outputs.baseline }} + + cargo-semver-checks: + needs: [check-if-lib, get-baseline] + if: ${{ needs.check-if-lib.outputs.is_lib == 'true' && needs.get-baseline.outputs.baseline != ''}} + runs-on: ubuntu-latest + steps: + - name: Fetch Repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Install stable toolchain + uses: actions-rust-lang/setup-rust-toolchain@v1 + + - name: Install cargo-bump + if: ${{ inputs.bump-version || inputs.release_type != 'none' }} + uses: taiki-e/install-action@v2 + with: + tool: cargo-bump + + - name: Run cargo bump + if: ${{ inputs.bump-version || inputs.release_type != 'none'}} + run: cargo bump ${{ inputs.bump-version || inputs.release_type}} + + - name: Install cargo-semver-checks + uses: taiki-e/install-action@v2 + with: + tool: cargo-semver-checks + + - name: Run cargo-semver-checks + run: cargo semver-checks --baseline-rev ${{ needs.get-baseline.outputs.baseline }}; diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 0000000..adcdceb --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,123 @@ +name: "[MAIN]: CI" + +permissions: + contents: write + +on: + workflow_dispatch: + workflow_call: + pull_request: + push: + branches: + - main + +jobs: + cargo-build: + name: Cargo Build + runs-on: ubuntu-latest + + steps: + - name: Fetch Repository + uses: actions/checkout@v4 + + - name: Install stable toolchain + uses: actions-rust-lang/setup-rust-toolchain@v1 + + - name: cargo build + run: cargo b + + cargo-fmt: + name: Cargo fmt + runs-on: ubuntu-latest + + steps: + - name: Fetch Repository + uses: actions/checkout@v4 + + - name: Install stable toolchain + uses: actions-rust-lang/setup-rust-toolchain@v1 + with: + components: rustfmt + + - name: Rustfmt Check + uses: actions-rust-lang/rustfmt@v1 + + cargo-clippy: + name: Cargo clippy + runs-on: ubuntu-latest + + steps: + - name: Fetch Repository + uses: actions/checkout@v4 + + - name: Install stable toolchain + uses: actions-rust-lang/setup-rust-toolchain@v1 + with: + components: clippy + + - name: Clippy Check + run: cargo clippy + + cargo-test: + name: Cargo test + runs-on: ubuntu-latest + + steps: + - name: Fetch Repository + uses: actions/checkout@v4 + + - name: Install stable toolchain + uses: actions-rust-lang/setup-rust-toolchain@v1 + + - name: Cargo test + run: cargo test + + typos-cli: + name: typos + runs-on: ubuntu-latest + steps: + - name: Fetch Repository + uses: actions/checkout@v4 + + - name: Install Typos + uses: taiki-e/install-action@v2 + with: + tool: typos-cli + + - name: run typos + run: typos + + taplo-toml-fmt: + + name: taplo fmt + runs-on: ubuntu-latest + steps: + - name: Fetch Repository + uses: actions/checkout@v4 + + - name: Install Taplo + uses: taiki-e/install-action@v2 + with: + tool: taplo-cli + + - name: Run Taplo + id: taplo + run: taplo fmt --check --diff + + markdownlint: + runs-on: ubuntu-latest + + steps: + - name: Fetch Repository + uses: actions/checkout@v4 + + - name: markdownlint-cli2-action + uses: DavidAnson/markdownlint-cli2-action@v15 + with: + globs: '**/*.md' + + cargo-deny: + uses: ./.github/workflows/cargo_deny.yaml + + check-msrv: + uses: ./.github/workflows/msrv.yaml diff --git a/.github/workflows/msrv.yaml b/.github/workflows/msrv.yaml new file mode 100644 index 0000000..cbf6d1a --- /dev/null +++ b/.github/workflows/msrv.yaml @@ -0,0 +1,89 @@ +name: MSRV + +permissions: + contents: write + +on: + workflow_call: + workflow_dispatch: + inputs: + update-msrv: + type: boolean + +jobs: + check-msrv: + if: ${{ !inputs.update-msrv }} + runs-on: ubuntu-latest + steps: + - name: Fetch Repository + uses: actions/checkout@v4 + + - name: Install stable toolchain + uses: actions-rust-lang/setup-rust-toolchain@v1 + + - uses: cargo-bins/cargo-binstall@main + + - name: Install cargo-msrv + # waiting for the stable release + run: cargo binstall cargo-msrv --version 0.16.0-beta.20 -y --force + + - name: Get current msrv + id: data-msrv + run: | + current_msrv=$(cargo msrv show --output-format minimal); + echo "current msrv: $current_msrv"; + echo "current=$current_msrv" >> "$GITHUB_OUTPUT"; + + - name: Run cargo msrv + run: cargo msrv verify --min ${{ steps.data-msrv.outputs.current }} + + - name: echo msrv info + if: failure() + run: | + echo "current msrv: ${{ steps.data-msrv.outputs.current }}"; + new_msrv=$(cargo msrv --output-format minimal); + echo "new msrv: $new_msrv"; + + update-msrv: + if: inputs.update-msrv + runs-on: ubuntu-latest + steps: + - name: Fetch Repository + uses: actions/checkout@v4 + + - run: git pull + + - name: Install stable toolchain + uses: actions-rust-lang/setup-rust-toolchain@v1 + + - uses: cargo-bins/cargo-binstall@main + + - name: Install cargo-msrv + # waiting for the stable release + run: cargo binstall cargo-msrv --version 0.16.0-beta.20 -y --force + + - name: Get msrv data + id: data-msrv + run: | + current_msrv=$(cargo msrv show --output-format minimal); + echo "current msrv: $current_msrv"; + echo "current=$current_msrv" >> "$GITHUB_OUTPUT"; + new_msrv=$(cargo msrv --output-format minimal --min $current_msrv); + echo "new msrv: $new_msrv"; + echo "new=$new_msrv" >> "$GITHUB_OUTPUT"; + + - name: Update cargo msrv + run: cargo msrv set ${{ steps.data-msrv.outputs.new }} + + - name: Update readme msrv + uses: jacobtomlinson/gha-find-replace@v3 + with: + find: ${{ steps.data-msrv.outputs.current }} + replace: ${{ steps.data-msrv.outputs.new }} + regex: false + include: "README.md" + + - name: Commit and Push + uses: stefanzweifel/git-auto-commit-action@v5 + with: + commit_message: "Update MSRV from [${{steps.data-msrv.outputs.current}}] to [${{steps.data-msrv.outputs.new}}]" diff --git a/.github/workflows/pre_release.yaml b/.github/workflows/pre_release.yaml new file mode 100644 index 0000000..b7e29dc --- /dev/null +++ b/.github/workflows/pre_release.yaml @@ -0,0 +1,47 @@ +name: Pre Release + +on: + workflow_call: + inputs: + version: + type: string + required: true + update-msrv: + type: boolean + workflow_dispatch: + inputs: + version: + description: "Bump version: (e.g. -> 3.1.4-alpha+159)" + required: true + type: string + update-msrv: + type: boolean + +permissions: + contents: write + +jobs: + run-ci: + uses: ./.github/workflows/ci.yaml + + cargo-semver-checks: + uses: ./.github/workflows/cargo_semver_checks.yaml + with: + bump-version: ${{ inputs.version }} + + add-notice: + uses: ./.github/workflows/add_notice.yaml + with: + commit_message: ${{ inputs.version }} + + bump-version: + needs: [cargo-semver-checks] + uses: ./.github/workflows/bump_version.yaml + with: + crate-version: ${{ inputs.version }} + + update-attribution: + needs: [bump-version] + uses: ./.github/workflows/update_attributions.yaml + with: + commit_message: ${{ inputs.version }} diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml new file mode 100644 index 0000000..285930a --- /dev/null +++ b/.github/workflows/publish.yaml @@ -0,0 +1,42 @@ +name: Publish + +on: + workflow_call: + workflow_dispatch: + +jobs: + check-secret-existence: + runs-on: ubuntu-latest + steps: + - name: Get secret + id: secret + run: | + token=${{ secrets.CARGO_REGISTRY_TOKEN != '' }}; + echo "token_exists=$token" >> "$GITHUB_OUTPUT"; + + - name: print if skip publish-crate + if: ${{ steps.secret.outputs.token_exists == 'false' }} + run: | + echo "add secrets.CARGO_REGISTRY_TOKEN to your github repo"; + + outputs: + secret_exists: ${{ steps.secret.outputs.token_exists }} + + publish-crate: + needs: [check-secret-existence] + if: ${{ needs.check-secret-existence.outputs.secret_exists == 'true' }} + runs-on: ubuntu-latest + steps: + - name: Fetch Repository + uses: actions/checkout@v4 + + - run: git pull + + - name: Install stable toolchain + uses: actions-rust-lang/setup-rust-toolchain@v1 + + - name: Cargo Publish + uses: katyo/publish-crates@v2 + with: + registry-token: ${{ secrets.CARGO_REGISTRY_TOKEN }} + ignore-unpublished-changes: true diff --git a/.github/workflows/update_attributions.yaml b/.github/workflows/update_attributions.yaml new file mode 100644 index 0000000..38935c1 --- /dev/null +++ b/.github/workflows/update_attributions.yaml @@ -0,0 +1,33 @@ +name: Update Attributions + +on: + workflow_call: + inputs: + commit_message: + type: string + workflow_dispatch: + +jobs: + update-attributions: + runs-on: ubuntu-latest + steps: + - name: Fetch Repository + uses: actions/checkout@v4 + + - run: git pull + + - name: Install stable toolchain + uses: actions-rust-lang/setup-rust-toolchain@v1 + + - name: Install cargo-attribution + uses: taiki-e/install-action@v2 + with: + tool: cargo-attribution + + - name: Run cargo attribution + run: cargo attribution + + - name: Commit and Push + uses: stefanzweifel/git-auto-commit-action@v5 + with: + commit_message: "[${{ inputs.commit_message || 'Manual run' }}]: Update Attributions" diff --git a/.github/workflows/weekly.yaml b/.github/workflows/weekly.yaml new file mode 100644 index 0000000..2db0ce2 --- /dev/null +++ b/.github/workflows/weekly.yaml @@ -0,0 +1,22 @@ +name: Weekly Checks + +on: + schedule: + - cron: "0 0 * * 0" + +permissions: + contents: write + +jobs: + run-ci: + uses: ./.github/workflows/ci.yaml + + add-notice: + uses: ./.github/workflows/add_notice.yaml + with: + commit_message: "Weekly run" + + update-attribution: + uses: ./.github/workflows/update_attributions.yaml + with: + commit_message: "Weekly run" diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ea8c4bf --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/target diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000..2ae3a79 --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,7 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "rust_cicd_template" +version = "0.1.0" diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..f095537 --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,18 @@ +[package] +name = "rust_cicd_template" # todo!("Change name") +description = "A rust ci/cd template for github" # todo!("Change description") +version = "0.1.0" +edition = "2021" +license = "CC0-1.0 OR MIT OR Apache-2.0" # todo!("Change licenses") +rust-version = "1.56.1" # todo!("Change rust-version (MSRV) you want to support") + +[dependencies] + +# https://doc.rust-lang.org/cargo/reference/profiles.html +# https://github.com/johnthagen/min-sized-rust +[profile.release] +codegen-units = 1 +lto = true +opt-level = "z" +panic = "abort" +strip = true diff --git a/LICENSE-Apache-2.0 b/LICENSE-Apache-2.0 new file mode 100644 index 0000000..1b5ec8b --- /dev/null +++ b/LICENSE-Apache-2.0 @@ -0,0 +1,176 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS diff --git a/LICENSE-CC0-1.0 b/LICENSE-CC0-1.0 new file mode 100644 index 0000000..0e259d4 --- /dev/null +++ b/LICENSE-CC0-1.0 @@ -0,0 +1,121 @@ +Creative Commons Legal Code + +CC0 1.0 Universal + + CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE + LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN + ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS + INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES + REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS + PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM + THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED + HEREUNDER. + +Statement of Purpose + +The laws of most jurisdictions throughout the world automatically confer +exclusive Copyright and Related Rights (defined below) upon the creator +and subsequent owner(s) (each and all, an "owner") of an original work of +authorship and/or a database (each, a "Work"). + +Certain owners wish to permanently relinquish those rights to a Work for +the purpose of contributing to a commons of creative, cultural and +scientific works ("Commons") that the public can reliably and without fear +of later claims of infringement build upon, modify, incorporate in other +works, reuse and redistribute as freely as possible in any form whatsoever +and for any purposes, including without limitation commercial purposes. +These owners may contribute to the Commons to promote the ideal of a free +culture and the further production of creative, cultural and scientific +works, or to gain reputation or greater distribution for their Work in +part through the use and efforts of others. + +For these and/or other purposes and motivations, and without any +expectation of additional consideration or compensation, the person +associating CC0 with a Work (the "Affirmer"), to the extent that he or she +is an owner of Copyright and Related Rights in the Work, voluntarily +elects to apply CC0 to the Work and publicly distribute the Work under its +terms, with knowledge of his or her Copyright and Related Rights in the +Work and the meaning and intended legal effect of CC0 on those rights. + +1. Copyright and Related Rights. A Work made available under CC0 may be +protected by copyright and related or neighboring rights ("Copyright and +Related Rights"). Copyright and Related Rights include, but are not +limited to, the following: + + i. the right to reproduce, adapt, distribute, perform, display, + communicate, and translate a Work; + ii. moral rights retained by the original author(s) and/or performer(s); +iii. publicity and privacy rights pertaining to a person's image or + likeness depicted in a Work; + iv. rights protecting against unfair competition in regards to a Work, + subject to the limitations in paragraph 4(a), below; + v. rights protecting the extraction, dissemination, use and reuse of data + in a Work; + vi. database rights (such as those arising under Directive 96/9/EC of the + European Parliament and of the Council of 11 March 1996 on the legal + protection of databases, and under any national implementation + thereof, including any amended or successor version of such + directive); and +vii. other similar, equivalent or corresponding rights throughout the + world based on applicable law or treaty, and any national + implementations thereof. + +2. Waiver. To the greatest extent permitted by, but not in contravention +of, applicable law, Affirmer hereby overtly, fully, permanently, +irrevocably and unconditionally waives, abandons, and surrenders all of +Affirmer's Copyright and Related Rights and associated claims and causes +of action, whether now known or unknown (including existing as well as +future claims and causes of action), in the Work (i) in all territories +worldwide, (ii) for the maximum duration provided by applicable law or +treaty (including future time extensions), (iii) in any current or future +medium and for any number of copies, and (iv) for any purpose whatsoever, +including without limitation commercial, advertising or promotional +purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each +member of the public at large and to the detriment of Affirmer's heirs and +successors, fully intending that such Waiver shall not be subject to +revocation, rescission, cancellation, termination, or any other legal or +equitable action to disrupt the quiet enjoyment of the Work by the public +as contemplated by Affirmer's express Statement of Purpose. + +3. Public License Fallback. Should any part of the Waiver for any reason +be judged legally invalid or ineffective under applicable law, then the +Waiver shall be preserved to the maximum extent permitted taking into +account Affirmer's express Statement of Purpose. In addition, to the +extent the Waiver is so judged Affirmer hereby grants to each affected +person a royalty-free, non transferable, non sublicensable, non exclusive, +irrevocable and unconditional license to exercise Affirmer's Copyright and +Related Rights in the Work (i) in all territories worldwide, (ii) for the +maximum duration provided by applicable law or treaty (including future +time extensions), (iii) in any current or future medium and for any number +of copies, and (iv) for any purpose whatsoever, including without +limitation commercial, advertising or promotional purposes (the +"License"). The License shall be deemed effective as of the date CC0 was +applied by Affirmer to the Work. Should any part of the License for any +reason be judged legally invalid or ineffective under applicable law, such +partial invalidity or ineffectiveness shall not invalidate the remainder +of the License, and in such case Affirmer hereby affirms that he or she +will not (i) exercise any of his or her remaining Copyright and Related +Rights in the Work or (ii) assert any associated claims and causes of +action with respect to the Work, in either case contrary to Affirmer's +express Statement of Purpose. + +4. Limitations and Disclaimers. + + a. No trademark or patent rights held by Affirmer are waived, abandoned, + surrendered, licensed or otherwise affected by this document. + b. Affirmer offers the Work as-is and makes no representations or + warranties of any kind concerning the Work, express, implied, + statutory or otherwise, including without limitation warranties of + title, merchantability, fitness for a particular purpose, non + infringement, or the absence of latent or other defects, accuracy, or + the present or absence of errors, whether or not discoverable, all to + the greatest extent permissible under applicable law. + c. Affirmer disclaims responsibility for clearing rights of other persons + that may apply to the Work or any use thereof, including without + limitation any person's Copyright and Related Rights in the Work. + Further, Affirmer disclaims responsibility for obtaining any necessary + consents, permissions or other rights required for any use of the + Work. + d. Affirmer understands and acknowledges that Creative Commons is not a + party to this document and has no duty or obligation with respect to + this CC0 or use of the Work. diff --git a/LICENSE-MIT b/LICENSE-MIT new file mode 100644 index 0000000..59f49a9 --- /dev/null +++ b/LICENSE-MIT @@ -0,0 +1,25 @@ +MIT License + +Permission is hereby granted, free of charge, to any +person obtaining a copy of this software and associated +documentation files (the "Software"), to deal in the +Software without restriction, including without +limitation the rights to use, copy, modify, merge, +publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice +shall be included in all copies or substantial portions +of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF +ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED +TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT +SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR +IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. diff --git a/NOTICE b/NOTICE new file mode 100644 index 0000000..0abfa18 --- /dev/null +++ b/NOTICE @@ -0,0 +1,2 @@ +SPDX-License-Identifier: CC0-1.0 OR MIT OR Apache-2.0 +-> todo! remove this notices diff --git a/README.md b/README.md new file mode 100644 index 0000000..ea8fa70 --- /dev/null +++ b/README.md @@ -0,0 +1,165 @@ +# Rust CI/CI template + +![License](https://img.shields.io/badge/license-MIT%2FApache-blue.svg) +[![Crates.io](https://img.shields.io/crates/v/rust_cicd_template.svg)](https://crates.io/crates/rust_cicd_template) +![Minimum Supported Rust Version](https://img.shields.io/badge/MSRV-1.56.1+-red) +[![CI](https://github.com/ameknite/rust_cicd_template/workflows/CI/badge.svg)](https://github.com/ameknite/rust_cicd_template/actions?workflow=CI) + +Template to maintain a rust project running CI/CD. + + + +## CI Workflow + +[ci.yaml](./.github/workflows/ci.yaml) + +This workflow will run every time you push to main or make a pull request. You can also run the workflow manually in github. + +It will run: + +- cargo build: Compiling for ubuntu-latest. +- cargo [fmt](https://github.com/rust-lang/rustfmt): Rust Formatter. +- cargo [clippy](https://github.com/rust-lang/rust-clippy): Lints. +- cargo test: Execute unit and integration tests. +- [typos](https://crates.io/crates/typos): + - Source code spell checker. + - Check for the [typos.toml](./typos.toml) file. + - docs: +- [taplo fmt](https://taplo.tamasfe.dev/): Toml formatter. +- [markdownlint-cli2](https://github.com/DavidAnson/markdownlint-cli2): Markdown linter and formatter. +- [cargo deny](https://github.com/EmbarkStudios/cargo-deny): + - Check for licenses, bans, advisories and sources. + - Check for the [deny.toml](./deny.toml) file. + - template: + - docs: +- [cargo audit](https://crates.io/crates/cargo-audit): + - Check for security vulnerabilities. + - Uses the [advisory-db](https://github.com/RustSec/advisory-db/) +- [cargo msrv](https://github.com/foresterre/cargo-msrv): Keep the rustc version on check. + +## CD Workflow + +[build_and_release](./.github/workflows/build_and_release.yaml) + +This workflow will only run manually throw github. + +It will: + +- Validate your input version with regex (e.g. v3.1.4-alpha+159). +- Run the ci workflow. +- Run [cargo semver-checks](https://crates.io/crates/cargo-semver-checks): + - Lint your crate API changes for semver violations. + - This will only run if you crate is a library. + - Uses your previous tag as a baseline. +- Run [add-notice](https://crates.io/crates/add-notice): + - Add header notices to your rust files. + - Check for the [NOTICEe file](./NOTICE). + - Auto-commit. +- Run [cargo-bump](https://crates.io/crates/cargo-bump): + - Bump the current version of the Cargo.toml + - Uses the input version if provided. + - Auto-commit. +- Run [cargo-attributions](https://crates.io/crates/cargo-attribution) + - Comply with licenses distribution. + - Add licenses, notices and metadata of your dependencies. + - Crate an [attribution folder](./attribution/) + - Auto-commit. +- Create a new tag: + - Uses the input version if provided. + - It's created only if the tag not exists. +- Create a new github release: + - Uses [create-gh-release-action](https://github.com/taiki-e/create-gh-release-action/tree/v1/) + - Includes your changelog if matches the same version. + - Uses the created tag as a reference. +- Build and Release in Github + - Using [upload-rust-binary-action](https://www.github.com/taiki-e/upload-rust-binary-action/tree/v1/) + - And [setup-cross-toolchain-action](https://github.com/taiki-e/setup-cross-toolchain-action/tree/v1/) + - Only builds if your crate contains a binary crate. + - Uses the created tag as a reference. + - Bundle the attribution folder with licenses and notices. + - Create checksum with sha256. + - It builds for linux: gnu (x86_64|aarch64) and musl (x86_64|aarch64) + - It builds for windows: msvc (x86_64|aarch64) and gnu (x86_64) + - It builds for mac-os (x86_64|aarch64) +- Publish the create to crates.io: + - Only if you have the secrets.CARGO_REGISTRY_TOKEN setup + +### How to use the Build and Release workflow + +You will run this directly in your Github repo -> Section `Actions` -> `[Main] Build & Release` workflow. -> `Run workflow` button. + +Here you can do three things to run the workflow: + + 1. Write the new version you want to release: + - The version is in the form of: + - Version parts: ${MAJOR}.${MINOR}.${PATCH}-${PRE-RELEASE}+${BUILD} + - Example: 3.1.4-alpha+159 + 2. Select the release_type you want: + - `patch`, `minor` and `major`. + - It will use your current crate version as a baseline. + - Keep in `none` if you only want the writing version. + 3. Keep all with the defaults (without version and release_type = none) + - It will use your current crate version as a baseline. + - Run if you already update your crate version + - Useful for testing when you already run the workflow. + +## Dependabot + +This template includes a setup for dependabot and a workflow for auto-merge. + +- It will update packages for cargo and github-actions weekly + +- For rust: + - It will create pull request in groups. + - One group for patch updates, one for minor updates and one for major updates. + - It will auto-merge the pull request if passes ci. + +- For github-actions: + - It will create a pull request in groups. + - Only one group for the updates. + - It will auto-merge the pull request if passes ci. + +## Other workflows + +This template uses [workflow call](https://docs.github.com/en/actions/using-workflows/reusing-workflows) and [workflow dispatch](https://docs.github.com/en/actions/using-workflows/manually-running-a-workflow) to reuse workflows and be able to run them individually. So you can run various jobs of the ci/ci workflow independently. + +Some workflows to consider: + +- [weekly-workflow](./.github/workflows/weekly.yaml) + - Run the ci workflow. + - Add notices to new files. + - Keep the licenses of your dependencies in sync with the dependabot updates. +- [msrv.yaml](./.github/workflows/msrv.yaml) + - This workflow includes a boolean to able to update your msrv. + - It will run cargo-msrv to update your `rust-version` in Cargo.toml + - If you uses the MSRV in your README.md it will also updated it. +- [cache.yaml](./.github/workflows/msrv.yaml) + - To clean the caches generated for the workflows. + - Run if you have problems with the cache. +- [add_notice.yaml](./.github/workflows/add_notice.yaml) + - To replace and update your notices + - To apply notices to other kind of files. + - To use different comment styles. +- [publish.yaml](./.github/workflows/publish.yaml) + - To publish your crate to crates.io + +## What to change if you want to use this template + +- Change [this file](.). +- Change the metadata in [Cargo.toml](./Cargo.toml) +- Change the licenses files. Right now uses [LICENSE-CC0-1.0](./LICENSE-CC0-1.0), [LICENSE-MIT](./LICENSE-MIT) +and [LICENSE-Apache-2.0](./LICENSE-Apache-2.0). +- Change the [deny.toml](./deny.toml) file. +- Change the [NOTICE] file: + - Remove the notice in [main.rs](./deny.toml) + - Or you can run add-notice --remove before you update the NOTICE file. + +## LICENSE + +SPDX-License-Identifier: CC0-1.0 OR MIT OR Apache-2.0 + +Licensed under a triple license at your option: + +- [CC0-1.0](LICENSE-CC0-1.0) license +- [MIT](LICENSE-MIT) license +- [Apache-2.0](LICENSE-Apache-2.0) license diff --git a/attribution/dependencies.toml b/attribution/dependencies.toml new file mode 100644 index 0000000..4177f1a --- /dev/null +++ b/attribution/dependencies.toml @@ -0,0 +1 @@ +dependencies = [] diff --git a/attribution/licenses/Apache-2.0 b/attribution/licenses/Apache-2.0 new file mode 100644 index 0000000..1b5ec8b --- /dev/null +++ b/attribution/licenses/Apache-2.0 @@ -0,0 +1,176 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS diff --git a/attribution/licenses/CC0-1.0 b/attribution/licenses/CC0-1.0 new file mode 100644 index 0000000..0e259d4 --- /dev/null +++ b/attribution/licenses/CC0-1.0 @@ -0,0 +1,121 @@ +Creative Commons Legal Code + +CC0 1.0 Universal + + CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE + LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN + ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS + INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES + REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS + PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM + THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED + HEREUNDER. + +Statement of Purpose + +The laws of most jurisdictions throughout the world automatically confer +exclusive Copyright and Related Rights (defined below) upon the creator +and subsequent owner(s) (each and all, an "owner") of an original work of +authorship and/or a database (each, a "Work"). + +Certain owners wish to permanently relinquish those rights to a Work for +the purpose of contributing to a commons of creative, cultural and +scientific works ("Commons") that the public can reliably and without fear +of later claims of infringement build upon, modify, incorporate in other +works, reuse and redistribute as freely as possible in any form whatsoever +and for any purposes, including without limitation commercial purposes. +These owners may contribute to the Commons to promote the ideal of a free +culture and the further production of creative, cultural and scientific +works, or to gain reputation or greater distribution for their Work in +part through the use and efforts of others. + +For these and/or other purposes and motivations, and without any +expectation of additional consideration or compensation, the person +associating CC0 with a Work (the "Affirmer"), to the extent that he or she +is an owner of Copyright and Related Rights in the Work, voluntarily +elects to apply CC0 to the Work and publicly distribute the Work under its +terms, with knowledge of his or her Copyright and Related Rights in the +Work and the meaning and intended legal effect of CC0 on those rights. + +1. Copyright and Related Rights. A Work made available under CC0 may be +protected by copyright and related or neighboring rights ("Copyright and +Related Rights"). Copyright and Related Rights include, but are not +limited to, the following: + + i. the right to reproduce, adapt, distribute, perform, display, + communicate, and translate a Work; + ii. moral rights retained by the original author(s) and/or performer(s); +iii. publicity and privacy rights pertaining to a person's image or + likeness depicted in a Work; + iv. rights protecting against unfair competition in regards to a Work, + subject to the limitations in paragraph 4(a), below; + v. rights protecting the extraction, dissemination, use and reuse of data + in a Work; + vi. database rights (such as those arising under Directive 96/9/EC of the + European Parliament and of the Council of 11 March 1996 on the legal + protection of databases, and under any national implementation + thereof, including any amended or successor version of such + directive); and +vii. other similar, equivalent or corresponding rights throughout the + world based on applicable law or treaty, and any national + implementations thereof. + +2. Waiver. To the greatest extent permitted by, but not in contravention +of, applicable law, Affirmer hereby overtly, fully, permanently, +irrevocably and unconditionally waives, abandons, and surrenders all of +Affirmer's Copyright and Related Rights and associated claims and causes +of action, whether now known or unknown (including existing as well as +future claims and causes of action), in the Work (i) in all territories +worldwide, (ii) for the maximum duration provided by applicable law or +treaty (including future time extensions), (iii) in any current or future +medium and for any number of copies, and (iv) for any purpose whatsoever, +including without limitation commercial, advertising or promotional +purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each +member of the public at large and to the detriment of Affirmer's heirs and +successors, fully intending that such Waiver shall not be subject to +revocation, rescission, cancellation, termination, or any other legal or +equitable action to disrupt the quiet enjoyment of the Work by the public +as contemplated by Affirmer's express Statement of Purpose. + +3. Public License Fallback. Should any part of the Waiver for any reason +be judged legally invalid or ineffective under applicable law, then the +Waiver shall be preserved to the maximum extent permitted taking into +account Affirmer's express Statement of Purpose. In addition, to the +extent the Waiver is so judged Affirmer hereby grants to each affected +person a royalty-free, non transferable, non sublicensable, non exclusive, +irrevocable and unconditional license to exercise Affirmer's Copyright and +Related Rights in the Work (i) in all territories worldwide, (ii) for the +maximum duration provided by applicable law or treaty (including future +time extensions), (iii) in any current or future medium and for any number +of copies, and (iv) for any purpose whatsoever, including without +limitation commercial, advertising or promotional purposes (the +"License"). The License shall be deemed effective as of the date CC0 was +applied by Affirmer to the Work. Should any part of the License for any +reason be judged legally invalid or ineffective under applicable law, such +partial invalidity or ineffectiveness shall not invalidate the remainder +of the License, and in such case Affirmer hereby affirms that he or she +will not (i) exercise any of his or her remaining Copyright and Related +Rights in the Work or (ii) assert any associated claims and causes of +action with respect to the Work, in either case contrary to Affirmer's +express Statement of Purpose. + +4. Limitations and Disclaimers. + + a. No trademark or patent rights held by Affirmer are waived, abandoned, + surrendered, licensed or otherwise affected by this document. + b. Affirmer offers the Work as-is and makes no representations or + warranties of any kind concerning the Work, express, implied, + statutory or otherwise, including without limitation warranties of + title, merchantability, fitness for a particular purpose, non + infringement, or the absence of latent or other defects, accuracy, or + the present or absence of errors, whether or not discoverable, all to + the greatest extent permissible under applicable law. + c. Affirmer disclaims responsibility for clearing rights of other persons + that may apply to the Work or any use thereof, including without + limitation any person's Copyright and Related Rights in the Work. + Further, Affirmer disclaims responsibility for obtaining any necessary + consents, permissions or other rights required for any use of the + Work. + d. Affirmer understands and acknowledges that Creative Commons is not a + party to this document and has no duty or obligation with respect to + this CC0 or use of the Work. diff --git a/attribution/licenses/MIT b/attribution/licenses/MIT new file mode 100644 index 0000000..31aa793 --- /dev/null +++ b/attribution/licenses/MIT @@ -0,0 +1,23 @@ +Permission is hereby granted, free of charge, to any +person obtaining a copy of this software and associated +documentation files (the "Software"), to deal in the +Software without restriction, including without +limitation the rights to use, copy, modify, merge, +publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice +shall be included in all copies or substantial portions +of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF +ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED +TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT +SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR +IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. diff --git a/attribution/self.toml b/attribution/self.toml new file mode 100644 index 0000000..a6dde85 --- /dev/null +++ b/attribution/self.toml @@ -0,0 +1,8 @@ +[self] +name = "rust_cicd_template" +version = "0.1.0" +description = "A rust ci/cd template for github" +license = "CC0-1.0 OR MIT OR Apache-2.0" +notices = [ + "(c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and", +] diff --git a/deny.toml b/deny.toml new file mode 100644 index 0000000..ec95b05 --- /dev/null +++ b/deny.toml @@ -0,0 +1,43 @@ +# https://github.com/EmbarkStudios/cargo-deny/blob/main/deny.template.toml + +[graph] +targets = [] +all-features = true +no-default-features = false + +[output] +feature-depth = 1 + +[advisories] +ignore = [] + +[licenses] +allow = ["CC0-1.0", "MIT", "Apache-2.0"] # todo!("Change the licenses") +confidence-threshold = 0.8 +exceptions = [] + +[licenses.private] +ignore = false +registries = [] + +[bans] +multiple-versions = "warn" +wildcards = "warn" +highlight = "all" +workspace-default-features = "allow" +external-default-features = "allow" +allow = [] +deny = [] +skip = [] +skip-tree = [] + +[sources] +unknown-registry = "deny" +unknown-git = "deny" +allow-registry = ["https://github.com/rust-lang/crates.io-index"] +allow-git = [] + +[sources.allow-org] +# github = [""] +# gitlab = [""] +# bitbucket = [""] diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..8f3581e --- /dev/null +++ b/src/main.rs @@ -0,0 +1,7 @@ +// SPDX-License-Identifier: CC0-1.0 OR MIT OR Apache-2.0 +// -> todo! remove this notices + +fn main() { + println!("Hello, world!"); + todo!("he") +} diff --git a/typos.toml b/typos.toml new file mode 100644 index 0000000..ffccc54 --- /dev/null +++ b/typos.toml @@ -0,0 +1,11 @@ +# https://github.com/crate-ci/typos/blob/master/docs/reference.md + +[files] +extend-exclude = [] + +[default.extend-identifiers] + +[default.extend-words] + +[default] +extend-ignore-identifiers-re = []