diff --git a/.github/workflows/release-workflow.yml b/.github/workflows/release-workflow.yml new file mode 100644 index 000000000..0effb0442 --- /dev/null +++ b/.github/workflows/release-workflow.yml @@ -0,0 +1,104 @@ +name: Release workflow +# This workflow is triggered on creating tags to master or an opendistro release branch +on: + push: + tags: + - 'v*' + +jobs: + build: + strategy: + matrix: + java: [13] + # Job name + name: Build Index Management with JDK ${{ matrix.java }} + # This job runs on Linux + runs-on: ubuntu-latest + steps: + # This step uses the checkout Github action: https://github.com/actions/checkout + - name: Checkout Branch + uses: actions/checkout@v2 + # This step uses the setup-java Github action: https://github.com/actions/setup-java + - name: Set Up JDK ${{ matrix.java }} + uses: actions/setup-java@v1 + with: + java-version: ${{ matrix.java }} + + # Building zip, deb and rpm files + - name: Build with Gradle + run: ./gradlew build buildDeb buildRpm --no-daemon -Dbuild.snapshot=false + + - name: Create Artifact Path + run: | + mkdir -p index-management-artifacts + cp ./build/distributions/*.zip index-management-artifacts + cp ./build/distributions/*.deb index-management-artifacts + cp ./build/distributions/*.rpm index-management-artifacts + echo ::set-env name=TAG_VERSION::${GITHUB_REF/refs\/tags\//} + + # AWS authentication + - name: Configure AWS Credentials + uses: aws-actions/configure-aws-credentials@v1 + with: + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + aws-region: us-west-2 + + # This step uses the upload-artifact Github action: https://github.com/actions/upload-artifact + - name: Upload Artifacts to S3 + run: | + s3_path=s3://artifacts.opendistroforelasticsearch.amazon.com/downloads + aws s3 cp index-management-artifacts/*.zip $s3_path/elasticsearch-plugins/opendistro-index-management/ + aws s3 cp index-management-artifacts/*.deb $s3_path/debs/opendistro-index-management/ + aws s3 cp index-management-artifacts/*.rpm $s3_path/rpms/opendistro-index-management/ + aws cloudfront create-invalidation --distribution-id ${{ secrets.DISTRIBUTION_ID }} --paths '/downloads/*' + + - name: Create Github Draft Release + id: create_release + uses: actions/create-release@v1.0.0 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ github.ref }} + release_name: Release ${{ env.TAG_VERSION }} + draft: true + prerelease: false + + # Upload the release with .zip as asset + - name: Upload Release Asset + uses: actions/upload-release-asset@v1.0.1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_name: index-management-artifacts.zip + asset_path: ./build/distributions/*.zip + asset_content_type: application/zip + + # Upload the release with .rpm as asset + - name: Upload Release Asset + uses: actions/upload-release-asset@v1.0.1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_name: index-management-artifacts.rpm + asset_path: ./build/distributions/*.rpm + asset_content_type: application/zip + + # Upload the release with .deb as asset + - name: Upload Release Asset + uses: actions/upload-release-asset@v1.0.1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_name: index-management-artifacts.deb + asset_path: ./build/distributions/*.deb + asset_content_type: application/zip + + - name: Upload Workflow Artifacts + uses: actions/upload-artifact@v1 + with: + name: index-management-plugin + path: index-management-artifacts diff --git a/.github/workflows/test-and-build-workflow.yml b/.github/workflows/test-and-build-workflow.yml index 647a0875e..9362a96be 100644 --- a/.github/workflows/test-and-build-workflow.yml +++ b/.github/workflows/test-and-build-workflow.yml @@ -18,7 +18,7 @@ jobs: steps: # This step uses the checkout Github action: https://github.com/actions/checkout - name: Checkout Branch - uses: actions/checkout@v1 + uses: actions/checkout@v2 # This step uses the setup-java Github action: https://github.com/actions/setup-java - name: Set Up JDK ${{ matrix.java }} uses: actions/setup-java@v1