diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index ec7c4b1a..14a069fa 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -20,11 +20,17 @@ jobs: - name: Fetch all tags run: git fetch --force --tags - - name: Set up Go + - name: Setup Go uses: actions/setup-go@v5 with: go-version-file: go.mod + - name: Setup Python + uses: actions/setup-python@v5 + with: + python-version: '3.12' + - run: python -m pip install --upgrade pip twine wheel setuptools + - name: Install Snapcraft uses: samuelmeuli/action-snapcraft@v2 @@ -43,10 +49,11 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.SNAPCRAFT_STORE_CREDENTIALS }} - - name: Publish to NPM and Rubygems + - name: Publish to NPM, Rubygems and PyPI env: NPM_API_KEY: ${{ secrets.NPM_API_KEY }} RUBYGEMS_API_KEY: ${{ secrets.RUBYGEMS_API_KEY }} + PYPI_API_KEY: ${{ secrets.PYPI_API_KEY }} run: | cat << EOF > ~/.npmrc //registry.npmjs.org/:_authToken=${NPM_API_KEY} @@ -58,6 +65,17 @@ jobs: :rubygems_api_key: ${RUBYGEMS_API_KEY} EOF chmod 0600 ~/.gem/credentials + cat << EOF > ~/.pypirc + [distutils] + index-servers = + lefthook + + [lefthook] + repository = https://upload.pypi.org/legacy/ + username = __token__ + password = ${PYPI_API_KEY} + EOF + chmod 0600 ~/.pypirc cd packaging/ ruby pack.rb prepare ruby pack.rb publish diff --git a/packaging/pack.rb b/packaging/pack.rb index d0aba12d..1579fb6f 100755 --- a/packaging/pack.rb +++ b/packaging/pack.rb @@ -122,6 +122,11 @@ def put_binaries end def publish + puts "Publishing to PyPI..." + cd(File.join(__dir__, "pypi")) + system("python setup.py sdist bdist_wheel", exception: true) + system("python -m twine upload --verbose --repository lefthook dist/*", exception: true) + puts "Publishing lefthook npm..." cd(File.join(__dir__, "npm")) Dir["lefthook*"].each do |package| @@ -139,7 +144,7 @@ def publish cd(File.join(__dir__, "npm-installer")) system("npm publish --access public", exception: true) - puts "Publishing lefthook gem..." + puts "Publishing to Rubygems..." cd(File.join(__dir__, "rubygems")) system("rake build", exception: true) system("gem push pkg/*.gem", exception: true)