Skip to content

Commit

Permalink
Merge pull request #2 from MekDrop/master
Browse files Browse the repository at this point in the history
Automatic yarn releases
  • Loading branch information
MekDrop authored Nov 7, 2020
2 parents 24ba264 + f479aba commit cbad361
Show file tree
Hide file tree
Showing 11 changed files with 131 additions and 617 deletions.
6 changes: 1 addition & 5 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,4 @@ insert_final_newline = false
charset = utf-8
indent_style = tab
trim_trailing_whitespace = true
tab_width = 4

[{package.json,.travis.yml}]
indent_style = space
indent_size = 2
tab_width = 4
123 changes: 123 additions & 0 deletions .github/workflows/autorelease.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
name: Autorelease

on:
schedule:
- cron: '0 */24 * * *'

jobs:
do-release:
runs-on: ubuntu-latest
steps:
- name: Checking auto code...
uses: actions/checkout@v2
with:
fetch-depth: 0
submodules: recursive

- name: Fetching last yarn information...
id: last_yarn_release
run: |
API_CONTENT=$(curl -sL https://api.github.com/repos/yarnpkg/yarn/releases/latest)
echo "::set-output name=tag::$(echo "$API_CONTENT" | jq -r '.tag_name')"
echo "::set-output name=url::$(echo "$API_CONTENT" | jq -r '.html_url')"
echo "::set-output name=version::$(echo "$API_CONTENT" | jq -r '.tag_name' | cut -c2- )"
- name: Getting last similar release tag...
id: similar_release_tag
run: |
echo "::set-output name=value::$(git tag -l --sort=-committerdate | grep ^${{ steps.last_yarn_release.outputs.tag }} | grep - | head -n 1)"
- name: Getting last similar release hash...
id: similar_release_hash
run: |
if [ "${{ steps.similar_release_tag.outputs.value }}" == "" ]; then
echo "::set-output name=value::"
else
echo "::set-output name=value::$(git show-ref -s ${{ steps.similar_release_tag.outputs.value }})"
fi;
- name: Calculating last release variant...
id: last_release_variant
run: |
echo "::set-output name=value::$(echo '${{ steps.similar_release_tag.outputs.value }}' | cut -f2- -d-)"
- name: Calculating new release variant...
id: new_release_variant
run: |
VARIANT='${{ steps.last_release_variant.outputs.value }}'
if [ "$VARIANT" == "" ]; then
VARIANT=1
elif [ "${{ steps.last_yarn_release.outputs.tag }}" == "${{ steps.similar_release_tag.outputs.value }}" ]; then
VARIANT=1
elif [ "${{ steps.similar_release_hash.outputs.value }}" != "$GITHUB_SHA" ]; then
VARIANT=$(($VARIANT + 1))
fi;
echo "::set-output name=value::$VARIANT"
- name: Generating release message...
id: new_release_msg
run: |
NEWLINE=$'\n'
NEW_RELEASE_MESSAGE="Installs [Yarn ${{ steps.last_yarn_release.outputs.tag }}](${{ steps.last_yarn_release.outputs.url }})"
NEW_RELEASE_MESSAGE="${NEW_RELEASE_MESSAGE}${NEWLINE}Installer build is ${{ steps.new_release_variant.outputs.value }}"
if [ "${{ steps.new_release_variant.outputs.value }}" != "1" ]; then
CHANGES_BETWEEN_COMMITS=$(git log --oneline ${{ steps.similar_release_hash.outputs.value }}..HEAD | grep -v Merge | while read line ; do echo " * $line" ; done)
NEW_RELEASE_MESSAGE="${NEW_RELEASE_MESSAGE}${NEWLINE}${NEWLINE}Installer changes:${NEWLINE}${CHANGES_BETWEEN_COMMITS}"
fi;
NEW_RELEASE_MESSAGE="${NEW_RELEASE_MESSAGE//'%'/'%25'}"
NEW_RELEASE_MESSAGE="${NEW_RELEASE_MESSAGE//$'\n'/'%0A'}"
NEW_RELEASE_MESSAGE="${NEW_RELEASE_MESSAGE//$'\r'/'%0D'}"
echo "::set-output name=value::$NEW_RELEASE_MESSAGE"
- name: Calculating new release tag...
id: new_release_tag
run: |
echo "::set-output name=value::${{ steps.last_yarn_release.outputs.tag }}-${{ steps.new_release_variant.outputs.value }}"
- name: Creating composer.json...
uses: DamianReeves/write-file-action@v1.0
with:
path: composer.json
write-mode: overwrite
contents: |
{
"name": "imponeer/composer-yarn-installer",
"type": "library",
"description": "Installs specific yarn version in vendor/",
"license": "MIT",
"keywords": [
"yarn",
"frontend",
"javascript"
],
"authors": [
{
"name": "Raimondas Rimkevičius",
"email": "github@mekdrop.name"
}
],
"require": {
"mariusbuescher/node-composer": ">1.2.2"
},
"provides": {
"yarn": "${{ steps.last_yarn_release.outputs.version }}"
}
}
- name: Trying to commit changes...
uses: stefanzweifel/git-auto-commit-action@v4
id: auto-commit-action
with:
commit_message: Yarn updated to ${{ steps.last_yarn_release.outputs.tag }}

- name: Creating release...
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.new_release_tag.outputs.value }}
release_name: ${{ steps.new_release_tag.outputs.value }}
body: ${{ steps.new_release_msg.outputs.value }}
draft: false
prerelease: false
if: steps.auto-commit-action.outputs.changes_detected == 'true'
114 changes: 0 additions & 114 deletions .travis.yml

This file was deleted.

16 changes: 7 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,26 +1,24 @@
[![License](https://img.shields.io/github/license/imponeer/composer-yarn-installer.svg?maxAge=2592000)](LICENSE) [![Test Status](https://travis-ci.org/imponeer/composer-yarn-installer.svg?branch=master)](https://travis-ci.org/imponeer/composer-yarn-installer) [![PHP from Packagist](https://img.shields.io/packagist/php-v/imponeer/composer-yarn-installer.svg)](https://php.net)
[![Packagist](https://img.shields.io/packagist/v/imponeer/composer-yarn-installer.svg)](https://packagist.org/packages/imponeer/composer-yarn-installer)
[![License](https://img.shields.io/github/license/imponeer/composer-yarn-installer.svg?maxAge=2592000)](LICENSE)
[![Packagist](https://img.shields.io/packagist/v/imponeer/composer-yarn-installer.svg)](https://packagist.org/packages/imponeer/composer-yarn-installer)
[![Packagist](https://img.shields.io/packagist/dm/imponeer/composer-yarn-installer.svg)](https://packagist.org/packages/imponeer/composer-yarn-installer)

# Composer Yarn Installer

Composer plugin that installs [Yarn](https://yarnpkg.com/) to /vendor/bin path.
Composer extension that installs [Yarn](https://yarnpkg.com/) to vendor bin path.

## Usage

Easiest way to do that is to execute composer command from console:

```bash
composer require imponeer/composer-yarn-installer
```

## Configuration
## Versioning

It's possible a bit to configure plugin. For that some configuration options can be added to composer.json `extra` section.
The package will be automatically updated each time when new yarn version is released.

| Key | Possible values | Default | What does? |
|-----|-----------------|---------|-------------|
| yarn_version | rc<br />latest<br />nighty<br />MAJOR.MINOR.REVISION | latest | Specifies what yarn version should be installed |
So, if you need to use specific yarn version for example 0.11.x, you can specify in composer.json with `"imponeer/composer-yarn-installer":"0.11.*"` line.

## How to contribute?

Expand Down
47 changes: 0 additions & 47 deletions composer.json

This file was deleted.

2 changes: 0 additions & 2 deletions opt/.gitignore

This file was deleted.

19 changes: 0 additions & 19 deletions src/Events.php

This file was deleted.

14 changes: 0 additions & 14 deletions src/Exceptions/BadVersionFormatException.php

This file was deleted.

14 changes: 0 additions & 14 deletions src/Exceptions/FileCantBeDownloadException.php

This file was deleted.

Loading

0 comments on commit cbad361

Please sign in to comment.