From b31f820797f3b63621359528724f7455d0d56521 Mon Sep 17 00:00:00 2001 From: svacas Date: Wed, 27 Oct 2021 14:37:21 -0300 Subject: [PATCH] Setup release action --- .github/release.yml | 21 ++++++++++ .github/workflows/release.yml | 73 +++++++++++++++++++++++++++++++++++ update-version.sh | 24 ++++++++++++ 3 files changed, 118 insertions(+) create mode 100644 .github/release.yml create mode 100644 .github/workflows/release.yml create mode 100755 update-version.sh diff --git a/.github/release.yml b/.github/release.yml new file mode 100644 index 000000000..44baf588a --- /dev/null +++ b/.github/release.yml @@ -0,0 +1,21 @@ +# release.yml + +changelog: + + exclude: + labels: + - ignore-for-release + + categories: + + - title: New Features + labels: + - enhancement + + - title: Bug fixes + labels: + - bug + + - title: Other Changes + labels: + - "*" diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 000000000..75177e45e --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,73 @@ +name: Mule Migration Assistant Release + +on: + push: + # Sequence of patterns matched against refs/tags + tags: + - 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10 + +jobs: + + release: + + runs-on: ubuntu-latest + + steps: + + - name: checkout + uses: actions/checkout@v2 + + - name: Set up JDK 1.8 + uses: actions/setup-java@v1 + with: + java-version: 1.8 + + - name: maven-settings-xml-action + uses: whelk-io/maven-settings-xml-action@v10 + with: + repositories: '[{ "id": "mulesoft-public", "url": "https://repository.mulesoft.org/nexus/content/repositories/public" }, + { "id": "mule-releases", "url": "https://repository.mulesoft.org/releases" }]' + + - name: log-settings + run: cat \/home\/runner\/.m2\/settings.xml + + - name: Build with Maven + run: mvn --settings /home/runner/.m2/settings.xml clean install --file pom.xml + + - name: Guess Release Version + run: | + echo "RELEASE_VERSION=$(echo '${{github.ref}}' | sed -e 's,.*/v\(.*\),\1,')" >> $GITHUB_ENV + + #GH RELEASE + - name: Create Release + id: create_release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ github.ref }} + release_name: ${{ github.ref }} + draft: true + prerelease: false + + - name: Upload Release Asset tgz + id: upload-release-asset-tgz + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps + asset_path: ./runner/target/mule-migration-assistant-runner-${{env.RELEASE_VERSION}}.tar.gz + asset_name: mule-migration-assistant-runner-${{env.RELEASE_VERSION}}.tar.gz + asset_content_type: application/gzip + + - name: Upload Release Asset zip + id: upload-release-asset-zip + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps + asset_path: ./runner/target/mule-migration-assistant-runner-${{env.RELEASE_VERSION}}.zip + asset_name: mule-migration-assistant-runner-${{env.RELEASE_VERSION}}.zip + asset_content_type: application/zip diff --git a/update-version.sh b/update-version.sh new file mode 100755 index 000000000..dba91fb5f --- /dev/null +++ b/update-version.sh @@ -0,0 +1,24 @@ +#!/bin/bash + +set -e + +current=$(cat pom.xml | grep '.*' | head -1 | sed 's/.*\([^<]*\).*/\1/') + +if [[ -z $current ]] + then + echo "Current version not found!" + exit 1 +fi + +read -p "Enter version to update to (current is ${current}): " -r +echo +if [[ $REPLY =~ ^[1-9]+\.[0-9]+\.[0-9]+(-SNAPSHOT)?$ ]] +then + mvn versions:set -DnewVersion=${REPLY} + pushd target-modules + mvn versions:set -DnewVersion=${REPLY} + popd target-modules +else + echo "Invalid version: $REPLY" + exit 2 +fi