From 43dce77e9abbace45ac40322256cb1985137c5e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Raimondas=20Rimkevi=C4=8Dius?= Date: Fri, 6 Nov 2020 15:52:05 +0200 Subject: [PATCH 1/2] autorelease github action --- .github/workflows/autorelease.yml | 127 ++++++++++++++++++++++++++++++ 1 file changed, 127 insertions(+) create mode 100644 .github/workflows/autorelease.yml diff --git a/.github/workflows/autorelease.yml b/.github/workflows/autorelease.yml new file mode 100644 index 0000000..fec4853 --- /dev/null +++ b/.github/workflows/autorelease.yml @@ -0,0 +1,127 @@ +name: Do automatic release + +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": { + "imponeer/composer-nodejs-installer": "*" + }, + "extra": { + "mariusbuescher": { + "node-composer": { + "yarn-version": "${{ 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' From fe542c0bce2d1d7fbf5755605f56ba789b26051d Mon Sep 17 00:00:00 2001 From: MekDrop Date: Sat, 7 Nov 2020 00:01:56 +0000 Subject: [PATCH 2/2] Yarn updated to v1.22.10 --- composer.json | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 composer.json diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..49be21d --- /dev/null +++ b/composer.json @@ -0,0 +1,27 @@ +{ + "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": { + "imponeer/composer-nodejs-installer": "*" + }, + "extra": { + "mariusbuescher": { + "node-composer": { + "yarn-version": "1.22.10", + } + } + } +} \ No newline at end of file