-
Notifications
You must be signed in to change notification settings - Fork 0
133 lines (130 loc) · 5.3 KB
/
release-api.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
# TODO: update conda-forge recipe
name: dxApi Release
on:
workflow_dispatch:
inputs:
release-version:
description: 'dxApi version'
required: true
permissions:
contents: write
packages: write
jobs:
run-release:
name: dxApi Release
runs-on: ubuntu-20.04
steps:
- name: Git checkout
uses: actions/checkout@v2
- name: Version check
run: |
api_snapshot=`grep -c "SNAPSHOT" ./api/src/main/resources/application.conf || true`
if [ "$api_snapshot" -ne "0" ]; then
echo "dxApi version contains '-SNAPSHOT'; releases cannot have snapshot versions"
exit 1
fi
- name: Install java
uses: actions/setup-java@v1
with:
java-version: 11
- name: Install dxpy and other dependencies
run: |
sudo apt-get update
sudo apt-get install -y apt-transport-https wget git openssh-server tree python3 python3-pip python3-venv
pip3 install --upgrade pip
pip3 install setuptools wheel
pip3 install termcolor
pip3 install dxpy
pip3 install --upgrade pyOpenSSL
- name: Build Dependencies
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
# make sure we have latest dependency versions
sbt 'project common' publishLocal
- name: Unit Tests
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
AUTH_TOKEN: ${{ secrets.DX_STAGING_TOKEN }}
run: |
export PATH="$PATH:$HOME/.local/bin"
# set up DNAnexus staging environment
dx login --noprojects --staging --token $AUTH_TOKEN
PROJECT=dxCompiler_playground
dx select $PROJECT
sbt 'project api' test
- name: Assembly
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
sbt 'project api' assembly
mv ./api/target/dxApi.jar ./dxApi-${{ github.event.inputs.release-version }}.jar
- name: Scala formatting
run: |
sbt 'project api' scalafmtCheckAll
- name: Extract release notes and set version in application.conf files
id: update-release
run: |
# Update the config file with the newest version
sed -i 's/version.*$/version = "${{ github.event.inputs.release-version }}"/' ./api/src/main/resources/application.conf
# Extract release notes for the release into a temporary (unpushed) file
# It is expected the RELEASE_NOTES.md has already an entry for the version being
# released. The section should start with '## <version>', e.g. ## 1.0.0 2021-01-01
# The file will be read by the create-release step
RELEASE_NOTES_PATH="./api/release_notes_${{ github.event.inputs.release-version }}.md"
sed -n '/## ${{ github.event.inputs.release-version }}/,/##/p' api/RELEASE_NOTES.md | sed '1d; $d' > $RELEASE_NOTES_PATH
echo ::set-output name=release-notes-path::$(echo "${RELEASE_NOTES_PATH}")
- name: Commit changes to application.conf files
uses: EndBug/add-and-commit@v7
with:
message: 'Release ${{ github.event.inputs.release-version }}'
add: '[
"./api/src/main/resources/application.conf"
]'
push: false
tag: api-${{ github.event.inputs.release-version }}
- name: Create release entry
id: create-release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: api-${{ github.event.inputs.release-version }}
release_name: dxApi ${{ github.event.inputs.release-version }}
body_path: ${{ steps.update-release.outputs.release-notes-path }}
draft: true
prerelease: false
- name: Upload assembly JAR
id: upload-release-assembly
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
# This pulls from the "Create release entry" 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
upload_url: ${{ steps.create-release.outputs.upload_url }}
asset_path: ./dxApi-${{ github.event.inputs.release-version }}.jar
asset_name: dxApi-${{ github.event.inputs.release-version }}.jar
asset_content_type: application/jar
- name: Push local release branch and tag to origin
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git pull
git push origin HEAD:${{ github.ref }}
git push origin HEAD:api-${{ github.event.inputs.release-version }}
- name: Publish package
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
sbt 'project api' publish
- name: Rollback release if unsuccessfull
if: ${{ cancelled() || failure() }}
uses: author/action-rollback@stable
with:
release_id: ${{ steps.create-release.outputs.id }}
tag: api-${{ github.event.inputs.release-version }}
delete_orphan_tag: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}