-
Notifications
You must be signed in to change notification settings - Fork 0
146 lines (143 loc) · 7.8 KB
/
snapshot.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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
name: Publish Snapshot Workflow
on:
push:
branches:
- develop
workflow_dispatch:
permissions:
contents: read
packages: write
jobs:
publish:
name: Publish Snapshot
runs-on: ubuntu-20.04
steps:
- name: Git Checkout
uses: actions/checkout@v2
- name: Install Java
uses: actions/setup-java@v1
with:
java-version: 11
- name: Install other dependencies
run: |
sudo apt update -y && sudo apt install -y jq
- name: Delete existing snapshot versions
id: versions
run: |
set -x
common_version=`grep -o -P "\d+\.\d+\.\d+-SNAPSHOT" ./common/src/main/resources/application.conf || true`
if [ -z "$common_version" ]; then
echo "dxCommon version does not end in '-SNAPSHOT'; only snapshot versions are allowed in the develop branch"
exit 1
fi
common_query="{\"query\": \"query { repository(owner:\\\"dnanexus\\\", name:\\\"dxScala\\\") { packages(names:[\\\"com.dnanexus.dxcommon\\\"], first:1) { nodes { version(version:\\\"${common_version}\\\") { id } } } } }\" }"
common_version_json=`curl \
-X POST \
-H "Accept: application/vnd.github.package-deletes-preview+json" \
-H "Authorization: bearer ${{ secrets.GITHUB_TOKEN }}" \
-d "$common_query" \
https://api.github.com/graphql`
common_version_id=`echo $common_version_json | jq -r ".data.repository.packages.nodes[0].version.id"`
if [ "$common_version_id" != "null" ]; then
common_delete_query="{\"query\": \"mutation { deletePackageVersion(input:{packageVersionId:\\\"${common_version_id}\\\"}) { success }}\"}"
common_delete_json=`curl -X POST \
-H "Accept: application/vnd.github.package-deletes-preview+json" \
-H "Authorization: bearer ${{ secrets.GITHUB_TOKEN }}" \
-d "$common_delete_query" \
https://api.github.com/graphql`
common_result=`echo $common_delete_json | jq ".data.deletePackageVersion.success"`
if [ "$common_result" != "true" ]; then
echo "could not delete dxCommon version ${common_version} with package ID ${common_version_id}"
echo "$common_delete_json"
exit 1
fi
fi
api_version=`grep -o -P "\d+\.\d+\.\d+-SNAPSHOT" ./api/src/main/resources/application.conf || true`
if [ -z "$api_version" ]; then
echo "dxApi version does not end in '-SNAPSHOT'; only snapshot versions are allowed in the develop branch"
exit 1
fi
api_query="{\"query\": \"query { repository(owner:\\\"dnanexus\\\", name:\\\"dxScala\\\") { packages(names:[\\\"com.dnanexus.dxapi\\\"], first:1) { nodes { version(version:\\\"${api_version}\\\") { id } } } } }\" }"
api_version_json=`curl \
-X POST \
-H "Accept: application/vnd.github.package-deletes-preview+json" \
-H "Authorization: bearer ${{ secrets.GITHUB_TOKEN }}" \
-d "$api_query" \
https://api.github.com/graphql`
api_version_id=`echo $api_version_json | jq -r ".data.repository.packages.nodes[0].version.id"`
if [ "$api_version_id" != "null" ]; then
api_delete_query="{\"query\": \"mutation { deletePackageVersion(input:{packageVersionId:\\\"${api_version_id}\\\"}) { success }}\"}"
api_delete_json=`curl -X POST \
-H "Accept: application/vnd.github.package-deletes-preview+json" \
-H "Authorization: bearer ${{ secrets.GITHUB_TOKEN }}" \
-d "$api_delete_query" \
https://api.github.com/graphql`
api_result=`echo $api_delete_json | jq ".data.deletePackageVersion.success"`
if [ "$api_result" != "true" ]; then
echo "could not delete dxApi version ${api_version} with package ID ${api_version_id}"
echo "$api_delete_json"
exit 1
fi
fi
protocols_version=`grep -o -P "\d+\.\d+\.\d+-SNAPSHOT" ./protocols/src/main/resources/application.conf || true`
if [ -z "$protocols_version" ]; then
echo "dxFileAccessProtocols version does not end in '-SNAPSHOT'; only snapshot versions are allowed in the develop branch"
exit 1
fi
protocols_query="{\"query\": \"query { repository(owner:\\\"dnanexus\\\", name:\\\"dxScala\\\") { packages(names:[\\\"com.dnanexus.dxfileaccessprotocols\\\"], first:1) { nodes { version(version:\\\"${protocols_version}\\\") { id } } } } }\" }"
protocols_version_json=`curl \
-X POST \
-H "Accept: application/vnd.github.package-deletes-preview+json" \
-H "Authorization: bearer ${{ secrets.GITHUB_TOKEN }}" \
-d "$protocols_query" \
https://api.github.com/graphql`
protocols_version_id=`echo $protocols_version_json | jq -r ".data.repository.packages.nodes[0].version.id"`
if [ "$protocols_version_id" != "null" ]; then
protocols_delete_query="{\"query\": \"mutation { deletePackageVersion(input:{packageVersionId:\\\"${protocols_version_id}\\\"}) { success }}\"}"
protocols_delete_json=`curl -X POST \
-H "Accept: application/vnd.github.package-deletes-preview+json" \
-H "Authorization: bearer ${{ secrets.GITHUB_TOKEN }}" \
-d "$protocols_delete_query" \
https://api.github.com/graphql`
protocols_result=`echo $protocols_delete_json | jq ".data.deletePackageVersion.success"`
if [ "$protocols_result" != "true" ]; then
echo "could not delete dxFileAccessProtocols version ${protocols_version} with package ID ${protocols_version_id}"
echo "$protocols_delete_json"
exit 1
fi
fi
yaml_version=`grep -o -P "\d+\.\d+\.\d+-SNAPSHOT" ./yaml/src/main/resources/application.conf || true`
if [ -z "$yaml_version" ]; then
echo "dxYaml version does not end in '-SNAPSHOT'; only snapshot versions are allowed in the develop branch"
exit 1
fi
yaml_query="{\"query\": \"query { repository(owner:\\\"dnanexus\\\", name:\\\"dxScala\\\") { packages(names:[\\\"com.dnanexus.dxyaml\\\"], first:1) { nodes { version(version:\\\"${yaml_version}\\\") { id } } } } }\" }"
yaml_version_json=`curl \
-X POST \
-H "Accept: application/vnd.github.package-deletes-preview+json" \
-H "Authorization: bearer ${{ secrets.GITHUB_TOKEN }}" \
-d "$yaml_query" \
https://api.github.com/graphql`
yaml_version_id=`echo $yaml_version_json | jq -r ".data.repository.packages.nodes[0].version.id"`
if [ "$yaml_version_id" != "null" ]; then
yaml_delete_query="{\"query\": \"mutation { deletePackageVersion(input:{packageVersionId:\\\"${yaml_version_id}\\\"}) { success }}\"}"
yaml_delete_json=`curl -X POST \
-H "Accept: application/vnd.github.package-deletes-preview+json" \
-H "Authorization: bearer ${{ secrets.GITHUB_TOKEN }}" \
-d "$yaml_delete_query" \
https://api.github.com/graphql`
yaml_result=`echo $yaml_delete_json | jq ".data.deletePackageVersion.success"`
if [ "$yaml_result" != "true" ]; then
echo "could not delete dxYaml version ${yaml_version} with package ID ${yaml_version_id}"
echo "$yaml_delete_json"
exit 1
fi
fi
- name: Publish Snapshot
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
sbt 'project common' publish
sbt 'project api' publish
sbt 'project protocols' publish
sbt 'project yaml' publish