|
| 1 | +name: CD |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - 'v*' |
| 7 | + |
| 8 | +jobs: |
| 9 | + build: |
| 10 | + runs-on: ubuntu-latest |
| 11 | + |
| 12 | + steps: |
| 13 | + |
| 14 | + - name: Set up JDK 11 |
| 15 | + uses: actions/setup-java@v1 |
| 16 | + with: |
| 17 | + java-version: 11.0.x |
| 18 | + |
| 19 | + - name: Checkout security |
| 20 | + uses: actions/checkout@v1 |
| 21 | + |
| 22 | + - name: Build |
| 23 | + run: | |
| 24 | + mvn clean package -Padvanced -DskipTests |
| 25 | + artifact_zip=`ls $(pwd)/target/releases/opendistro_security-*.zip | grep -v admin-standalone` |
| 26 | + ./gradlew build buildDeb buildRpm --no-daemon -ParchivePath=$artifact_zip -Dbuild.snapshot=false |
| 27 | + mkdir artifacts |
| 28 | + cp $artifact_zip artifacts/ |
| 29 | + cp gradle-build/distributions/*.deb artifacts/ |
| 30 | + cp gradle-build/distributions/*.rpm artifacts/ |
| 31 | + zip -r artifacts.zip artifacts |
| 32 | + echo ::set-env name=TAG_VERSION::${GITHUB_REF/refs\/tags\//} |
| 33 | +
|
| 34 | + - name: Configure AWS Credentials |
| 35 | + uses: aws-actions/configure-aws-credentials@v1 |
| 36 | + with: |
| 37 | + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} |
| 38 | + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} |
| 39 | + aws-region: us-west-2 |
| 40 | + |
| 41 | + - name: Upload Artifacts to S3 |
| 42 | + run: | |
| 43 | + s3_path=s3://artifacts.opendistroforelasticsearch.amazon.com/downloads |
| 44 | + aws s3 cp artifacts/*.zip $s3_path/elasticsearch-plugins/opendistro-security/ |
| 45 | + aws s3 cp artifacts/*.deb $s3_path/debs/opendistro-security/ |
| 46 | + aws s3 cp artifacts/*.rpm $s3_path/rpms/opendistro-security/ |
| 47 | + aws cloudfront create-invalidation --distribution-id ${{ secrets.DISTRIBUTION_ID }} --paths '/downloads/*' |
| 48 | +
|
| 49 | + - name: Create Github Draft Release |
| 50 | + id: create_release |
| 51 | + |
| 52 | + env: |
| 53 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 54 | + with: |
| 55 | + tag_name: ${{ github.ref }} |
| 56 | + release_name: Release ${{ env.TAG_VERSION }} |
| 57 | + draft: true |
| 58 | + prerelease: false |
| 59 | + |
| 60 | + - name: Upload Release Asset |
| 61 | + id: upload-release-asset |
| 62 | + |
| 63 | + env: |
| 64 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 65 | + with: |
| 66 | + upload_url: ${{ steps.create_release.outputs.upload_url }} |
| 67 | + asset_name: artifacts.zip |
| 68 | + asset_path: artifacts.zip |
| 69 | + asset_content_type: application/zip |
| 70 | + |
| 71 | + - name: Upload Workflow Artifacts |
| 72 | + uses: actions/upload-artifact@v1 |
| 73 | + with: |
| 74 | + name: artifacts |
| 75 | + path: artifacts/ |
0 commit comments