Skip to content

Commit add46c3

Browse files
author
Xavier Arias
committed
Split GH actions configuration to simplify
1 parent a7a74dd commit add46c3

File tree

7 files changed

+87
-49
lines changed

7 files changed

+87
-49
lines changed

.github/workflows/gradle.yml .github/workflows/build.yml

+1-20
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Web3j
1+
name: Build
22

33
on:
44
push:
@@ -30,13 +30,6 @@ jobs:
3030
run: ./gradlew integration-tests:test -Pintegration-tests=true
3131
build:
3232
runs-on: ubuntu-latest
33-
env:
34-
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
35-
OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
36-
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
37-
BINTRAY_USER: ${{ secrets.BINTRAY_USER }}
38-
BINTRAY_KEY: ${{ secrets.BINTRAY_KEY }}
39-
GITHUB_PERSONAL_ACCESS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4033
steps:
4134
- uses: actions/checkout@v2
4235
- name: Set up JDK 1.8
@@ -53,18 +46,6 @@ jobs:
5346
run: chmod +x gradlew
5447
- name: Build
5548
run: ./gradlew check jacocoTestReport
56-
- name: Decrypt secret key
57-
run: openssl aes-256-cbc -K ${{ secrets.GPG_KEY }} -iv ${{ secrets.GPG_IV }} -in web3j.asc.enc -out web3j.asc -d
58-
if: github.base_ref == ''
59-
- name: Publish master
60-
run: ./gradlew publish
61-
if: github.base_ref == ''
62-
- name: Release
63-
uses: web3j/[email protected]
64-
with:
65-
version: ${GITHUB_REF#'release/'}
66-
github-token: ${{ secrets.GITHUB_TOKEN }}
67-
if: contains(github.ref, '/release/')
6849
- name: After success
6950
run: bash <(curl -s https://codecov.io/bash)
7051
if: ${{ success() }}
+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Release
2+
3+
on:
4+
workflow_run:
5+
workflows: [ 'Build' ]
6+
branches: [ master ]
7+
types: [ completed ]
8+
9+
jobs:
10+
publish-snapshot:
11+
if: ${{ github.event.workflow_run.conclusion == 'success' }}
12+
runs-on: ubuntu-latest
13+
env:
14+
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
15+
OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
16+
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
17+
BINTRAY_USER: ${{ secrets.BINTRAY_USER }}
18+
BINTRAY_KEY: ${{ secrets.BINTRAY_KEY }}
19+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
20+
steps:
21+
- uses: actions/checkout@v2
22+
- name: Set up JDK 1.8
23+
uses: actions/setup-java@v1
24+
with:
25+
java-version: 1.8
26+
- name: Cache Gradle packages
27+
uses: actions/cache@v2
28+
with:
29+
path: ~/.gradle/caches
30+
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
31+
restore-keys: ${{ runner.os }}-gradle
32+
- name: Grant execute permission for gradlew
33+
run: chmod +x gradlew
34+
- name: Decrypt secret key
35+
run: openssl aes-256-cbc -K ${{ secrets.GPG_KEY }} -iv ${{ secrets.GPG_IV }} -in web3j.asc.enc -out web3j.asc -d
36+
- name: Publish snapshot
37+
run: ./gradlew publish
38+

.github/workflows/release.yml

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: Publish snapshot
2+
3+
on:
4+
workflow_run:
5+
workflows: [ 'Build' ]
6+
branches: [ 'release/*' ]
7+
types: [ completed ]
8+
9+
jobs:
10+
release:
11+
if: ${{ github.event.workflow_run.conclusion == 'success' }}
12+
runs-on: ubuntu-latest
13+
env:
14+
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
15+
OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
16+
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
17+
BINTRAY_USER: ${{ secrets.BINTRAY_USER }}
18+
BINTRAY_KEY: ${{ secrets.BINTRAY_KEY }}
19+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
20+
steps:
21+
- uses: actions/checkout@v2
22+
- name: Set up JDK 1.8
23+
uses: actions/setup-java@v1
24+
with:
25+
java-version: 1.8
26+
- name: Cache Gradle packages
27+
uses: actions/cache@v2
28+
with:
29+
path: ~/.gradle/caches
30+
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
31+
restore-keys: ${{ runner.os }}-gradle
32+
- name: Grant execute permission for gradlew
33+
run: chmod +x gradlew
34+
- name: Decrypt secret key
35+
run: openssl aes-256-cbc -K ${{ secrets.GPG_KEY }} -iv ${{ secrets.GPG_IV }} -in web3j.asc.enc -out web3j.asc -d
36+
- name: Build and stage release
37+
run: ./gradlew publish bintrayUpload -Pversion=${{ GITHUB_REF#'release/' }}
38+
- name: Release
39+
run: ./gradlew closeAndReleaseRepository
40+
- name: GitHub release
41+
run: ./scripts/github-release.sh
42+
- name: Javadoc release
43+
run: ./gradlew -Dorg.ajoberstar.grgit.auth.username=${{ GITHUB_TOKEN }} core:gitPublishPush

core/build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def getTimestamp() {
4242

4343
ext {
4444
docsPath = 'web3j/web3j-docs'
45-
ghToken = System.getenv('GITHUB_PERSONAL_ACCESS_TOKEN')
45+
ghToken = System.getenv('GITHUB_TOKEN')
4646
}
4747

4848
gitPublish {

scripts/common.bash

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ configure_github_user() {
88
}
99

1010
github_clone() {
11-
git clone https://antonydenyer:${GITHUB_PERSONAL_ACCESS_TOKEN}@github.com/web3j/$1.git
11+
git clone https://antonydenyer:${GITHUB_TOKEN}@github.com/web3j/$1.git
1212
cd $1
1313
}
1414

scripts/github-release.sh

+3-3
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ ensure_version
2121

2222
ensure_product
2323

24-
export PREVIOUS_RELEASE=$(curl -H "Authorization: token ${GITHUB_PERSONAL_ACCESS_TOKEN}" -s https://api.github.com/repos/web3j/${PRODUCT}/releases/latest | jq -r '.target_commitish' )
24+
export PREVIOUS_RELEASE=$(curl -H "Authorization: token ${GITHUB_TOKEN}" -s https://api.github.com/repos/web3j/${PRODUCT}/releases/latest | jq -r '.target_commitish' )
2525
export CHANGELOG=$(git rev-list --format=oneline --abbrev-commit --max-count=50 ${PREVIOUS_RELEASE}..HEAD | jq --slurp --raw-input . )
2626

2727
echo "Creating a new release on GitHub with changes"
@@ -37,12 +37,12 @@ API_JSON="{
3737
}"
3838

3939

40-
export RESULT=$(curl -H "Authorization: token ${GITHUB_PERSONAL_ACCESS_TOKEN}" --data "$API_JSON" -s https://api.github.com/repos/web3j/${PRODUCT}/releases)
40+
export RESULT=$(curl -H "Authorization: token ${GITHUB_TOKEN}" --data "$API_JSON" -s https://api.github.com/repos/web3j/${PRODUCT}/releases)
4141
export UPLOAD_URL=$(echo ${RESULT} | jq -r ".upload_url")
4242

4343
for FILE in `find ./ -type f -name "${PRODUCT}-${VERSION}.*"`;
4444
do
45-
curl -H "Authorization: token ${GITHUB_PERSONAL_ACCESS_TOKEN}" -s "${UPLOAD_URL:0:-13}?name=$(basename -- $FILE)" -H "Content-Type: $(file -b --mime-type $FILE)" --data-binary @"${FILE}"
45+
curl -H "Authorization: token ${GITHUB_TOKEN}" -s "${UPLOAD_URL:0:-13}?name=$(basename -- $FILE)" -H "Content-Type: $(file -b --mime-type $FILE)" --data-binary @"${FILE}"
4646
done
4747

4848
echo "Release finished"

scripts/release-dependant.sh

-24
This file was deleted.

0 commit comments

Comments
 (0)