forked from opensearch-project/job-scheduler
-
Notifications
You must be signed in to change notification settings - Fork 0
123 lines (108 loc) · 4.57 KB
/
release-workflow.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
name: Release workflow
# This workflow is triggered on creating tags to main or an OpenSearch release branch
on:
push:
tags:
- 'v*'
jobs:
build:
strategy:
matrix:
java: [11]
# Job name
name: Build Job-scheduler with JDK ${{ matrix.java }}
# This job runs on Linux
runs-on: macos-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 job-scheduler-artifacts
cp ./build/distributions/*.zip job-scheduler-artifacts
cp ./build/distributions/*.zip job-scheduler-artifacts_zip
cp ./build/distributions/*.deb job-scheduler-artifacts
cp ./build/distributions/*.deb job-scheduler-artifacts_deb
cp ./build/distributions/*.rpm job-scheduler-artifacts
cp ./build/distributions/*.rpm job-scheduler-artifacts_rpm
echo "TAG_VERSION=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_ENV
# AWS authentication
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_STAGING_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_STAGING_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
shell: bash
run: |
zip=`ls build/distributions/*.zip`
rpm=`ls build/distributions/*.rpm`
deb=`ls build/distributions/*.deb`
# Inject the build number before the suffix
zip_outfile=`basename ${zip%.zip}-build-${GITHUB_RUN_NUMBER}.zip`
rpm_outfile=`basename ${rpm%.rpm}-build-${GITHUB_RUN_NUMBER}.rpm`
deb_outfile=`basename ${deb%.deb}-build-${GITHUB_RUN_NUMBER}.deb`
s3_prefix="s3://staging.artifacts.opendistroforelasticsearch.amazon.com/snapshots/elasticsearch-plugins/job-scheduler/"
echo "Copying ${zip} to ${s3_prefix}${zip_outfile}"
aws s3 cp --quiet $zip ${s3_prefix}${zip_outfile}
echo "Copying ${rpm} to ${s3_prefix}${rpm_outfile}"
aws s3 cp --quiet $rpm ${s3_prefix}${rpm_outfile}
echo "Copying ${deb} to ${s3_prefix}${deb_outfile}"
aws s3 cp --quiet $deb ${s3_prefix}${deb_outfile}
# Creating release draft
- name: Create Github Draft Release
id: create_release
uses: actions/[email protected]
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/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_name: job-scheduler-artifacts.zip
asset_path: job-scheduler-artifacts_zip
asset_content_type: application/zip
# Upload the release with .rpm as asset
- name: Upload Release Asset
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_name: job-scheduler-artifacts.rpm
asset_path: job-scheduler-artifacts_rpm
asset_content_type: application/zip
# Upload the release with .deb as asset
- name: Upload Release Asset
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_name: job-scheduler-artifacts.deb
asset_path: job-scheduler-artifacts_deb
asset_content_type: application/zip
- name: Upload Workflow Artifacts
uses: actions/upload-artifact@v1
with:
name: job-scheduler-plugin
path: job-scheduler-artifacts