Skip to content

Commit

Permalink
ci: publish packages in parallel
Browse files Browse the repository at this point in the history
  • Loading branch information
mrexox committed Oct 17, 2024
1 parent 7eb4eb6 commit 2341cd9
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 23 deletions.
74 changes: 56 additions & 18 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,6 @@ jobs:
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 @@ -56,40 +50,84 @@ jobs:
name: dist
path: dist.tar

publish-packages:
publish-npm:
needs: build
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: actions/checkout@v4
with:
fetch-depth: 0
- run: git fetch --force --tags

- name: Fetch all tags
run: git fetch --force --tags

- name: Download build binaries
uses: actions/download-artifact@v4
- uses: actions/download-artifact@v4
with:
name: dist
- run: tar -xvf dist.tar

- name: Publish to NPM, Rubygems and PyPI
- name: Publish to NPM
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}
EOF
chmod 0600 ~/.npmrc
cd packaging/
ruby pack.rb prepare
ruby pack.rb publish_npm
publish-gem:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- run: git fetch --force --tags

- uses: actions/download-artifact@v4
with:
name: dist
- run: tar -xvf dist.tar

- name: Publish to Rubygems
env:
RUBYGEMS_API_KEY: ${{ secrets.RUBYGEMS_API_KEY }}
run: |
mkdir -p ~/.gem/
cat << EOF > ~/.gem/credentials
---
:rubygems_api_key: ${RUBYGEMS_API_KEY}
EOF
chmod 0600 ~/.gem/credentials
cd packaging/
ruby pack.rb prepare
ruby pack.rb publish_gem
publish-pypi:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- run: git fetch --force --tags

- uses: actions/download-artifact@v4
with:
name: dist
- run: tar -xvf dist.tar

- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
- run: python -m pip install --upgrade pip twine wheel setuptools

- name: Publish to PyPI
env:
PYPI_API_KEY: ${{ secrets.PYPI_API_KEY }}
run: |
cat << EOF > ~/.pypirc
[distutils]
index-servers =
Expand All @@ -103,7 +141,7 @@ jobs:
chmod 0600 ~/.pypirc
cd packaging/
ruby pack.rb prepare
ruby pack.rb publish
ruby pack.rb publish_pypi
publish-homebrew:
needs: build
Expand Down
18 changes: 13 additions & 5 deletions packaging/pack.rb
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,12 @@ 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)
publish_pypi
publish_npm
publish_gem
end

def publish_npm
puts "Publishing lefthook npm..."
cd(File.join(__dir__, "npm"))
Dir["lefthook*"].each do |package|
Expand All @@ -143,13 +144,20 @@ def publish
puts "Publishing @evilmartians/lefthook-installer npm..."
cd(File.join(__dir__, "npm-installer"))
system("npm publish --access public", exception: true)
end

def publish_gem
puts "Publishing to Rubygems..."
cd(File.join(__dir__, "rubygems"))
system("rake build", exception: true)
system("gem push pkg/*.gem", exception: true)
end

puts "done"
def publish_pypi
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)
end

def replace_in_file(filepath, regexp, value)
Expand Down

0 comments on commit 2341cd9

Please sign in to comment.