diff --git a/.github/actions/setup-vcpkg/action.yml b/.github/actions/setup-vcpkg/action.yml new file mode 100644 index 0000000..293c7b9 --- /dev/null +++ b/.github/actions/setup-vcpkg/action.yml @@ -0,0 +1,33 @@ +name: Setup Vcpkg +description: Install a full vcpkg environment +inputs: + + vcpkgVersion: + description: Enter vcpkg version tag or stable or latest + required: false + default: latest + type: string + + vcpkgRoot: + description: Enter VCPKGROOT as vcpkg root path + required: false + default: /usr/local/vcpkg + type: string + + vcpkgDownload: + description: Enter VCPKGDOWNLOAD as vcpkg download path + required: false + default: /usr/local/vcpkg-downloads + type: string + +runs: + using: composite + steps: + - name: Setup vcpkg + run: | + git clone --depth 1 https://github.com/msclock/features.git /tmp/vcpkg + + sudo USERNAME="$USER" VCPKGVERSION="${{ inputs.vcpkgVersion }}" VCPKGROOT="${{ inputs.vcpkgRoot }}" \ + VCPKGDOWNLOAD="${{ inputs.vcpkgDownload }}" /tmp/vcpkg/src/vcpkg/install.sh + vcpkg --version + shell: bash diff --git a/.github/workflows/untrustedPR.yml b/.github/workflows/untrustedPR.yml deleted file mode 100644 index 00dc71e..0000000 --- a/.github/workflows/untrustedPR.yml +++ /dev/null @@ -1,178 +0,0 @@ -name: Check For Common Mistakes - -on: - pull_request: - -jobs: - Check: - runs-on: ubuntu-22.04 - - steps: - - name: Checkout - uses: actions/checkout@v4 - with: - fetch-depth: 50 - - - name: Checkout vcpkg - uses: actions/checkout@v4 - with: - repository: microsoft/vcpkg - fetch-depth: 1 - path: vcpkg - - - - name: Bootstrap - run: ./vcpkg/bootstrap-vcpkg.sh - - - name: Formatting - run: | - git config user.email github-actions - git config user.name github-actions@github.com - - git --version - - unset VCPKG_ROOT - - git diff --name-status --merge-base HEAD^ HEAD --diff-filter=MAR -- '*portfile.cmake' | sed 's/[MAR]\t*//' > .github-pr.changed-portfiles - if [ -s .github-pr.changed-portfiles ]; then (grep -n -H -E '(vcpkg_apply_patches|vcpkg_build_msbuild|vcpkg_extract_source_archive_ex)' $(cat .github-pr.changed-portfiles) || true) > .github-pr.deprecated-function; else touch .github-pr.deprecated-function; fi - if [ -s .github-pr.changed-portfiles ]; then (grep -n -H -E '(vcpkg_install_cmake|vcpkg_build_cmake|vcpkg_configure_cmake|vcpkg_fixup_cmake_targets)' $(cat .github-pr.changed-portfiles) || true) > .github-pr.deprecated-cmake; else touch .github-pr.deprecated-cmake; fi - git diff --name-status --merge-base HEAD^ HEAD --diff-filter=MAR -- '*vcpkg.json' | sed 's/[MAR]\t*//' > .github-pr.changed-manifest-files - cat .github-pr.changed-manifest-files | while read filename; do grep -q -E '"license": ' "$filename" || echo "$filename" || true; done > .github-pr.missing-license - cat .github-pr.changed-manifest-files | while read filename; do match=$(grep -oiP '"license": ".*\K(AGPL-1\.0|AGPL-3\.0|BSD-2-Clause-FreeBSD|BSD-2-Clause-NetBSD|bzip2-1\.0\.5|eCos-2\.0|GFDL-1\.1|GFDL-1\.2|GFDL-1\.3|GPL-1\.0|GPL-1\.0\+|GPL-2\.0|GPL-2\.0\+|GPL-2\.0-with-autoconf-exception|GPL-2\.0-with-bison-exception|GPL-2\.0-with-classpath-exception|GPL-2\.0-with-font-exception|GPL-2\.0-with-GCC-exception|GPL-3\.0|GPL-3\.0\+|GPL-3\.0-with-autoconf-exception|GPL-3\.0-with-GCC-exception|LGPL-2\.0|LGPL-2\.0\+|LGPL-2\.1|LGPL-2\.1\+|LGPL-3\.0|LGPL-3\.0\+|Nunit|StandardML-NJ|wxWindows)(?=[ "])' "$filename" || true); if [ ! -z "$match" ]; then echo "$filename (has deprecated license \"$match\")" ; fi ; done > .github-pr.deprecated-license - ./vcpkg/vcpkg format-manifest --all --convert-control - git diff > .github-pr.format-manifest - git add -u - git commit -m "tmp" --allow-empty - # HEAD^^ refers to the "main" commit that was merged into - git checkout HEAD^^ -- versions - git restore --staged versions - ./vcpkg/vcpkg x-add-version --all --skip-formatting-check | grep 'instead of "version-string"' | tee .github-pr.version-string.out || true - git checkout -- versions - ./vcpkg/vcpkg x-add-version --all --skip-formatting-check --skip-version-format-check | tee .github-pr.x-add-version.out || true - git diff > .github-pr.x-add-version.diff - git reset HEAD~ --mixed - - - name: Generate Reply - uses: actions/github-script@v6 - with: - script: | - const { promises: fs } = require('fs') - const add_version = (await fs.readFile('.github-pr.x-add-version.diff', 'utf8')).trim() - const add_version_out = (await fs.readFile('.github-pr.x-add-version.out', 'utf8')).trim() - const version_string_out = (await fs.readFile('.github-pr.version-string.out', 'utf8')).trim() - const format = (await fs.readFile('.github-pr.format-manifest', 'utf8')).trim() - const deprecated_function = (await fs.readFile('.github-pr.deprecated-function', 'utf8')).split('\n').filter(s => s.length > 0) - const deprecated_cmake = (await fs.readFile('.github-pr.deprecated-cmake', 'utf8')).split('\n').filter(s => s.length > 0) - const missing_license = (await fs.readFile('.github-pr.missing-license', 'utf8')).trim() - const deprecated_license = (await fs.readFile('.github-pr.deprecated-license', 'utf8')).trim() - - let approve = true; - if (format !== "") { - var format_output = ''; - format_output += "All vcpkg.json files must be formatted. To fix this problem, run:\n"; - format_output += "./vcpkg format-manifest ports/*/vcpkg.json\n"; - format_output += "\n"; - format_output += "It should make the following changes:"; - format_output += "```diff\n" + format + "\n```"; - core.error(format_output); - approve = false; - } - if (add_version_out !== "") { - var add_version_output = ''; - add_version_output += "PRs must add only one version, and must not modify any published versions.\n"; - add_version_output += "When making any changes to a library, the version or port-version in vcpkg.json must be modified, and the version database updated.\n"; - add_version_output += "Making the following changes will fix this problem:"; - add_version_output += "```diff\n" + add_version_out + "\n```"; - core.error(add_version_output); - approve = false; - } - if (version_string_out !== "") { - core.warning(version_string_out); - } - if (add_version !== "") { - var update_version_db_output = ''; - update_version_db_output += "After committing all other changes, the version database must be updated.\n"; - update_version_db_output += "This can be done by running the following commands after committing your changes:\n" - update_version_db_output += "\n" - update_version_db_output += "git add -u && git commit\n" - update_version_db_output += "git checkout ${{ github.event.pull_request.base.sha }} -- versions\n" - update_version_db_output += "./vcpkg x-add-version --all" - core.error(update_version_db_output); - approve = false; - } - - if (deprecated_function.length > 0) { - var deprecated_output = ''; - deprecated_output += "**You have modified or added at least one portfile where deprecated functions are used**\n" - deprecated_output += "If you feel able to do so, please consider migrating them to the new functions.\n"; - core.warning(deprecated_output); - - let deprecated_functions = { - vcpkg_extract_source_archive_ex: 'vcpkg_extract_source_archive https://learn.microsoft.com/en-us/vcpkg/maintainers/functions/vcpkg_extract_source_archive', - vcpkg_build_msbuild: 'vcpkg_install_msbuild https://learn.microsoft.com/en-us/vcpkg/maintainers/functions/vcpkg_install_msbuild', - vcpkg_apply_patches: 'the PATCHES arguments to the \"extract\" helpers (for example, vcpkg_from_github() (https://learn.microsoft.com/en-us/vcpkg/maintainers/functions/vcpkg_from_github))', - }; - for (let line of deprecated_function) { - // line has the format: :: 0) { - var deprecated_output = ''; - deprecated_output += "You have modified or added at least one portfile where deprecated functions are used.\n" - deprecated_output += "These functions have been forbidden in vcpkg, please migrating them to the new functions.\n"; - deprecated_output += "In the ports that use the new function vcpkg_cmake_configure, vcpkg_cmake_install, vcpkg_cmake_build or vcpkg_cmake_config_fixup, you have to add the corresponding dependencies:\n"; - deprecated_output += "```json\n"; - deprecated_output += '{\n "name": "vcpkg-cmake",\n "host": true\n},\n' - deprecated_output += '{\n "name": "vcpkg-cmake-config",\n "host": true\n}\n'; - deprecated_output += "```\n"; - core.error(deprecated_output); - - let deprecated_functions = { - vcpkg_install_cmake: 'vcpkg_cmake_install (from port vcpkg-cmake)', - vcpkg_install_cmake: 'vcpkg_cmake_install (from port vcpkg-cmake)', - vcpkg_build_cmake: 'vcpkg_cmake_build (from port vcpkg-cmake)', - vcpkg_configure_cmake: 'vcpkg_cmake_configure (Please remove the option PREFER_NINJA) (from port vcpkg-cmake)', - vcpkg_fixup_cmake_targets: 'vcpkg_cmake_config_fixup (from port vcpkg-cmake-config)', - }; - for (let line of deprecated_cmake) { - // line has the format: ::> $GITHUB_OUTPUT + + - name: Commit port hash + if: steps.filter-hash.outputs.ports == 'true' + uses: stefanzweifel/git-auto-commit-action@v5 + with: + file_pattern: ports/* + commit_message: ${{ steps.ports-last-commit-message.outputs.msg }} + push_options: --force + commit_options: --amend --no-edit + skip_fetch: true + + - name: Detect ports changes against default branch + id: filter-ports + uses: dorny/paths-filter@v2 + with: + list-files: shell + filters: | + ports: + - ports/** + + - name: Update versions + if: steps.filter-ports.outputs.ports == 'true' + run: | + for dir in ports/* ; do + vcpkg x-add-version ${dir##ports/} --overlay-ports=./ports \ + --x-builtin-registry-versions-dir=./versions/ \ + --x-builtin-ports-root=./ports + done + + - name: Detect versions changes against local + if: steps.filter-ports.outputs.ports == 'true' + id: filter-versions + uses: dorny/paths-filter@v2 + with: + list-files: shell + base: HEAD + filters: | + versions: + - versions/** + + - name: Get last commit message + if: steps.filter-versions.outputs.versions == 'true' + id: last-commit-message + run: | + echo "msg=$(git log -1 --pretty=%s)" >> $GITHUB_OUTPUT + + - name: Commit versions + if: steps.filter-versions.outputs.versions == 'true' + uses: stefanzweifel/git-auto-commit-action@v5 + with: + file_pattern: versions/* + commit_message: ${{ steps.last-commit-message.outputs.msg }} + push_options: --force + commit_options: --amend --no-edit + skip_fetch: true + + release: + name: release + runs-on: ubuntu-latest + permissions: + contents: write + needs: [pre-commit, format_and_update_ports] + + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + ref: ${{ github.head_ref }} + token: ${{ secrets.GITHUB_TOKEN }} + + - uses: actions/setup-node@v4 + with: + node-version: 20 + + - name: Semantic Release + uses: cycjimmy/semantic-release-action@v4 + id: semantic + with: + semantic_version: 22.0.5 + branches: | + [ + '+([0-9])?(.{+([0-9]),x}).x', + 'master', + 'main', + 'next', + 'next-major', + { + name: 'beta', + prerelease: true + }, + { + name: 'alpha', + prerelease: true + } + ] + extra_plugins: | + @semantic-release/changelog + @semantic-release/git + @semantic-release/exec + @semantic-release/github + conventional-changelog-conventionalcommits + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}