From f3dc46862ec2f79b548fd35daedce227b3c5bb95 Mon Sep 17 00:00:00 2001 From: Zak Stucke Date: Wed, 24 Jan 2024 12:51:32 +0200 Subject: [PATCH] Remove the zetch file again to make 100% sure thats it --- .zetch.lock | 22 +- release.yml | 325 ++++++++++++++++++ .../release.yml.zetch => release.yml.zetch | 3 +- 3 files changed, 337 insertions(+), 13 deletions(-) create mode 100644 release.yml rename .github/workflows/release.yml.zetch => release.yml.zetch (99%) diff --git a/.zetch.lock b/.zetch.lock index 3ecec135..ab3adf24 100644 --- a/.zetch.lock +++ b/.zetch.lock @@ -1,23 +1,23 @@ { "version": "0.0.2", "files": { - ".github/workflows/release.yml.zetch": "4be0ac2941be5459ae21ba87ac5eee2bdbc180ca0d0855bdc45491ac83a513bb", - "js/tsconfig.zetch.json": "fb5d57b825bb3c2f6dd4254bf939f2444e52946622a7f93b91e3acb75876ebbc", + "js/README.zetch.md": "efa793e656f3e6df26188bec7a3bdc5e96bb4d7c282081de7b1db64ffec42bd4", "py/README.zetch.md": "efa793e656f3e6df26188bec7a3bdc5e96bb4d7c282081de7b1db64ffec42bd4", - "CONTRIBUTING.zetch.md": "a41b09d39649a43accb86895fd7a5cbb79b036a8087d395e3f9f147540a0a39c", "CODE_OF_CONDUCT.zetch.md": "bf106326ffc75f5167cfde27c997c77c6b97c843a9e392b564355d0e70e50b97", "py_rust/LICENSE.zetch.md": "d2c12e539d357957b950a54a5477c3a9f87bd2b3ee707be7a4db7adaf5aacc2b", - "rust/README.zetch.md": "efa793e656f3e6df26188bec7a3bdc5e96bb4d7c282081de7b1db64ffec42bd4", + "LICENSE.zetch.md": "d2c12e539d357957b950a54a5477c3a9f87bd2b3ee707be7a4db7adaf5aacc2b", + "rust/LICENSE.zetch.md": "d2c12e539d357957b950a54a5477c3a9f87bd2b3ee707be7a4db7adaf5aacc2b", + "README.zetch.md": "0d59c21d31f828f7da4634696b9535a4eef9bb2fa84d8a8e6aa7034d0108e29f", + "py/LICENSE.zetch.md": "d2c12e539d357957b950a54a5477c3a9f87bd2b3ee707be7a4db7adaf5aacc2b", "js/LICENSE.zetch.md": "d2c12e539d357957b950a54a5477c3a9f87bd2b3ee707be7a4db7adaf5aacc2b", + "CONTRIBUTING.zetch.md": "a41b09d39649a43accb86895fd7a5cbb79b036a8087d395e3f9f147540a0a39c", + "rust/README.zetch.md": "efa793e656f3e6df26188bec7a3bdc5e96bb4d7c282081de7b1db64ffec42bd4", "docs/CODE_OF_CONDUCT.zetch.md": "bf106326ffc75f5167cfde27c997c77c6b97c843a9e392b564355d0e70e50b97", "py_rust/README.zetch.md": "efa793e656f3e6df26188bec7a3bdc5e96bb4d7c282081de7b1db64ffec42bd4", - "docs/LICENSE.zetch.md": "d2c12e539d357957b950a54a5477c3a9f87bd2b3ee707be7a4db7adaf5aacc2b", - "docs/CONTRIBUTING.zetch.md": "a41b09d39649a43accb86895fd7a5cbb79b036a8087d395e3f9f147540a0a39c", - "js/README.zetch.md": "efa793e656f3e6df26188bec7a3bdc5e96bb4d7c282081de7b1db64ffec42bd4", "docs/index.zetch.md": "efa793e656f3e6df26188bec7a3bdc5e96bb4d7c282081de7b1db64ffec42bd4", - "README.zetch.md": "0d59c21d31f828f7da4634696b9535a4eef9bb2fa84d8a8e6aa7034d0108e29f", - "rust/LICENSE.zetch.md": "d2c12e539d357957b950a54a5477c3a9f87bd2b3ee707be7a4db7adaf5aacc2b", - "py/LICENSE.zetch.md": "d2c12e539d357957b950a54a5477c3a9f87bd2b3ee707be7a4db7adaf5aacc2b", - "LICENSE.zetch.md": "d2c12e539d357957b950a54a5477c3a9f87bd2b3ee707be7a4db7adaf5aacc2b" + "js/tsconfig.zetch.json": "fb5d57b825bb3c2f6dd4254bf939f2444e52946622a7f93b91e3acb75876ebbc", + "docs/CONTRIBUTING.zetch.md": "a41b09d39649a43accb86895fd7a5cbb79b036a8087d395e3f9f147540a0a39c", + "docs/LICENSE.zetch.md": "d2c12e539d357957b950a54a5477c3a9f87bd2b3ee707be7a4db7adaf5aacc2b", + "release.yml.zetch": "140cdf945c685523a6f7c1c752b9a08c4668006def5c6e7ce28608fa720f53bb" } } \ No newline at end of file diff --git a/release.yml b/release.yml new file mode 100644 index 00000000..1dfeea73 --- /dev/null +++ b/release.yml @@ -0,0 +1,325 @@ +name: Package Release + +# A manual workflow, triggered from the UI +on: + workflow_dispatch: + branches: + - main + inputs: + py_release: + description: "Python Release" + type: boolean + required: false + default: false + py_version: + description: "Python Version (now 0.0.1)" + default: "0.0.1" + js_release: + description: "JS Release" + type: boolean + required: false + default: false + js_version: + description: "JS Version (now 0.0.20)" + default: "0.0.20" + py_rust_release: + description: "Rust-backed Python Release" + type: boolean + required: false + default: false + py_rust_version: + description: "Rust-backed Python Version (now 0.0.0)" + default: "0.0.0" + rust_release: + description: "Rust Release" + type: boolean + required: false + default: false + rust_version: + description: "Rust Version (now 0.0.20)" + default: "0.0.20" + +jobs: + commit_versions: + name: Bump Pkg Versions + runs-on: ubuntu-latest + permissions: + contents: write + pull-requests: write + outputs: + new-sha: ${{ steps.sha.outputs.SHA }} + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v4 + - uses: ./.github/actions/install-pre-commit + + - name: Set up PDM + if: ${{ inputs.py_release }} + uses: pdm-project/setup-pdm@v3 + with: + python-version: "3.12" + cache: true + cache-dependency-path: "py/pdm.lock" + - name: Update Python version + if: ${{ inputs.py_release }} + run: | + ./dev_scripts/pkg.sh ver_py_update ${{ inputs.py_version }} + + - name: Install Node.js + if: ${{ inputs.js_release }} + uses: actions/setup-node@v2 + with: + node-version: "20" + cache: npm + cache-dependency-path: "js/package-lock.json" + - name: Update JS version + if: ${{ inputs.js_release }} + run: | + ./dev_scripts/pkg.sh ver_js_update ${{ inputs.js_version }} + + # Formatting and checking uses nightly rather than stable: + - uses: dtolnay/rust-toolchain@nightly + if: ${{ inputs.py_rust_release }} || ${{ inputs.rust_release }} + with: + components: rustfmt, clippy + + - name: Update Rust-backed Python version + if: ${{ inputs.py_rust_release }} + run: | + ./dev_scripts/pkg.sh ver_py_rust_update ${{ inputs.py_rust_version }} + + - name: Update Rust version + if: ${{ inputs.rust_release }} + run: | + ./dev_scripts/pkg.sh ver_rust_update ${{ inputs.rust_version }} + + - name: add and format added files with pre-commit + # Running on staged change only as that's all that's needed, || true as don't want it to fail, just modify + run: | + git add . && + ./dev_scripts/test.sh pre_till_success && + git add . + + - name: Commit the new version to the repo + uses: EndBug/add-and-commit@v9 + with: + push: true + message: "chore: bump package versions for release" + author_name: github-actions + author_email: action@github.com + + - name: get sha + id: sha + run: | + sha_new=$(git rev-parse HEAD) + echo $sha_new + echo "::set-output name=SHA::$sha_new" + + - run: echo ${{ steps.sha.outputs.SHA }} + + # Rebuild docs each time this is run, note there is currently no versioning in the docs for each of the individually packages, will need to be added when a public package is being properly released + docs: + name: Docs Release + needs: [commit_versions] + runs-on: ubuntu-latest + permissions: + contents: write + pull-requests: write + steps: + - uses: actions/checkout@v4 + with: + ref: ${{ needs.commit_versions.outputs.new-sha }} + + - name: Set up PDM + uses: pdm-project/setup-pdm@v3 + with: + python-version: "3.12" + cache: true + cache-dependency-path: "docs/pdm.lock" + + - name: Install dependencies + run: | + pdm sync -p ./docs + + - name: Install Node.js + uses: actions/setup-node@v2 + with: + node-version: "20" + cache: npm + cache-dependency-path: "js/package-lock.json" + + - name: Build docs + run: | + ./dev_scripts/docs.sh build + + - name: Deploy to GitHub Pages + uses: crazy-max/ghaction-github-pages@v4 + with: + keep_history: true + target_branch: docs-site + build_dir: site + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + py_release: + name: Python Release + needs: [commit_versions] + # Run only if requested: + if: ${{ inputs.py_release }} + runs-on: ubuntu-latest + permissions: + contents: write + pull-requests: write + steps: + - uses: actions/checkout@v4 + with: + ref: ${{ needs.commit_versions.outputs.new-sha }} + + - name: Set up PDM + uses: pdm-project/setup-pdm@v3 + with: + python-version: "3.12" + cache: true + cache-dependency-path: "py/pdm.lock" + + - name: Publish package publicly to PyPI + run: | + export PDM_PUBLISH_USERNAME="__token__" + export PDM_PUBLISH_PASSWORD="${{ secrets.PYPI_TOKEN }}" + pdm publish -p ./py --repository pypi + + - name: Publish the release notes + uses: release-drafter/release-drafter@v5 + with: + publish: true + tag: "v${{ inputs.py_version }}_py" + name: "v${{ inputs.py_version }} - Python" + env: + GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" + + js_release: + name: JS Release + needs: [commit_versions] + # Run only if requested: + if: ${{ inputs.js_release }} + runs-on: ubuntu-latest + permissions: + contents: write + pull-requests: write + steps: + - uses: actions/checkout@v4 + with: + ref: ${{ needs.commit_versions.outputs.new-sha }} + + - name: Install Node.js + uses: actions/setup-node@v2 + with: + node-version: "20" + cache: npm + cache-dependency-path: "js/package-lock.json" + + - name: Install deps, build lib and copy package.json and README.md to dist which is published as root + run: | + cd js + npm install + npm run build + cp package.json dist/ + cp README.md dist/ + + - name: Publish publicly to NPM + run: | + cd js/dist + npm set //registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }} + npm publish + + - name: Publish the release notes + uses: release-drafter/release-drafter@v5 + with: + publish: true + tag: "v${{ inputs.js_version }}_js" + name: "v${{ inputs.js_version }} - JS" + env: + GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" + + py_rust_build: + needs: [commit_versions] + # Run only if requested: + if: ${{ inputs.py_rust_release }} + uses: ./.github/workflows/py-rust-build.yml + with: + new-sha: ${{ needs.commit_versions.outputs.new-sha }} + + py_rust_release: + name: Rust-backed Python Library Release + # Make needs multiline: + needs: [commit_versions, py_rust_build] + # Run only if requested: + if: ${{ inputs.py_rust_release }} + runs-on: ubuntu-latest + permissions: + contents: write + pull-requests: write + steps: + - uses: actions/checkout@v4 + with: + ref: ${{ needs.commit_versions.outputs.new-sha }} + + - name: get dist artifacts built in py_rust_build job + uses: actions/download-artifact@v3 + with: + name: py_rust_build_files + path: py_rust/dist + + - uses: actions/setup-python@v4 + with: + python-version: "3.12" + - run: pip install twine + + - name: Make sure release contents seem valid + run: twine check py_rust/dist/* + + - name: upload to pypi + run: twine upload py_rust/dist/* + env: + TWINE_USERNAME: __token__ + TWINE_PASSWORD: "${{ secrets.PYPI_TOKEN }}" + + - name: Publish the release notes + uses: release-drafter/release-drafter@v5 + with: + publish: true + tag: "v${{ inputs.py_rust_version }}_py_rs" + name: "v${{ inputs.py_rust_version }} - Rust-backed Python Library" + env: + GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" + + rs_release: + name: Rust Release + needs: [commit_versions] + # Run only if requested: + if: ${{ inputs.rust_release }} + runs-on: ubuntu-latest + permissions: + contents: write + pull-requests: write + steps: + - uses: actions/checkout@v4 + with: + ref: ${{ needs.commit_versions.outputs.new-sha }} + + - name: Install rust toolchain + uses: dtolnay/rust-toolchain@stable + + - name: upload to Crates.io + run: | + cd rust + cargo publish --token ${{ secrets.CRATES_TOKEN }} + + - name: Publish the release notes + uses: release-drafter/release-drafter@v5 + with: + publish: true + tag: "v${{ inputs.rust_version }}_rs" + name: "v${{ inputs.rust_version }} - Rust" + env: + GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" diff --git a/.github/workflows/release.yml.zetch b/release.yml.zetch similarity index 99% rename from .github/workflows/release.yml.zetch rename to release.yml.zetch index 20df5106..c11d4e4f 100644 --- a/.github/workflows/release.yml.zetch +++ b/release.yml.zetch @@ -100,8 +100,7 @@ jobs: run: | git add . && ./dev_scripts/test.sh pre_till_success && - git add . && - git reset .github/workflows/ + git add . - name: Commit the new version to the repo uses: EndBug/add-and-commit@v9