Skip to content

Commit

Permalink
ci: publish to PyPI
Browse files Browse the repository at this point in the history
  • Loading branch information
mrexox committed Oct 17, 2024
1 parent fd3d1d8 commit cca1296
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 3 deletions.
22 changes: 20 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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}
Expand All @@ -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
Expand Down
7 changes: 6 additions & 1 deletion packaging/pack.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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|
Expand All @@ -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)
Expand Down

0 comments on commit cca1296

Please sign in to comment.