Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/valentiniljaz/packagist-publish

Publish Composer package to Private Packagist using API
https://github.com/valentiniljaz/packagist-publish

Last synced: 24 days ago
JSON representation

Publish Composer package to Private Packagist using API

Awesome Lists containing this project

README

        

## Private Packagist Publish

Publish your package to Packagist.com using API. Very useful for PHP monorepos.

### Install

Add the package as dev dependency to your project:

```
composer require --dev valentiniljaz/packagist-publish
```

### Use

Publish your package:

```
./vendor/bin/packagist-publish
```

> Initial publish of the package must be done manually by uploading
> archive to Packagist.com

If you only need to prepare archive for publishing:

```
./vendor/bin/packagist-archive
```

Help about commands:

```
./vendor/bin/packagist-publish -h
./vendor/bin/packagist-archive -h
```

### How it works

#### 1) Builds zip archive using GIT

```
git archive -o HEAD[:]
```

> You must have all your changes committed.

#### 2) Publishes archive to Packagist.com using API endpoint

```
POST /api/packages//artifacts/
```

> You must provide Packagist API Key and Secret either
> by command params (--apiKey, --apiSecret)
> or by env variables (PACKAGIST_KEY, PACKAGIST_SECRET).
> Params have precedence over env vars.

#### Details

- If path to composer.json is not specified by command option it'll take the first composer.json it finds from current working dir upwards.
- For GIT ARCHIVE it needs to know the root of GIT repo; it'll take the first dir containing `.git` from current working dir upwards.
- Default destination for archive is the location of dir containing composer.json.
- If you need to ignore specific folder(s)/file(s) from archive you can use `.gitattributes` and set `export-ignore` attribute.

## Author

Valentin Iljaž

[[email protected]](mailto:[email protected])

## License

MIT