-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #137 from dhis2/simplify-publish-workflow
[skip publish] Simplify release process
- Loading branch information
Showing
14 changed files
with
175 additions
and
219 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,62 @@ | ||
name: Main | ||
|
||
on: | ||
push: | ||
pull_request: | ||
types: | ||
- closed | ||
branches: | ||
- 'main' | ||
- 'master' | ||
- 'beta' | ||
- main | ||
- master | ||
|
||
jobs: | ||
unit-test: | ||
uses: ./.github/workflows/job-test.yml | ||
name: Run tests | ||
if: ${{ github.event.pull_request.merged == true }} | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Set up JDK 17 | ||
uses: actions/setup-java@v4 | ||
with: | ||
java-version: 17 | ||
distribution: temurin | ||
cache: 'gradle' | ||
- name: Change wrapper permission | ||
run: chmod +x ./gradlew | ||
|
||
check-new-version: | ||
needs: unit-test | ||
uses: ./.github/workflows/job-check-new-version.yml | ||
- name: Test | ||
run: ./gradlew clean allTests | ||
|
||
publish: | ||
needs: check-new-version | ||
if: ${{ needs.check-new-version.outputs.isNewVersion == 'true' }} | ||
uses: ./.github/workflows/job-publish.yml | ||
secrets: inherit | ||
needs: unit-test | ||
if: ${{ github.event.pull_request.merged == true && !contains(github.event.pull_request.title, '[skip publish]') }} | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
- name: Set up JDK 17 | ||
uses: actions/setup-java@v4 | ||
with: | ||
java-version: 17 | ||
distribution: temurin | ||
cache: 'gradle' | ||
- name: Change wrapper permission | ||
run: chmod +x ./gradlew | ||
|
||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: 14.x | ||
|
||
- name: Publish Maven | ||
run: ./gradlew publishToSonatype closeAndReleaseSonatypeStagingRepository -PremoveSnapshotSuffix | ||
env: | ||
OSSRH_USERNAME: ${{ secrets.SONATYPE_OSSRH_USERNAME }} | ||
OSSRH_PASSWORD: ${{ secrets.SONATYPE_OSSRH_PASSWORD }} | ||
SIGNING_PRIVATE_KEY: ${{ secrets.PGP_PRIVATE_KEY }} | ||
SIGNING_PASSWORD: ${{ secrets.PGP_PASSPHRASE }} | ||
|
||
- name: Publish NPMJS | ||
run: ./.github/workflows/scripts/publish-npm-prod.sh | ||
env: | ||
NPMJS_TOKEN: ${{ secrets.DHIS2_BOT_NPM_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
name: Publish NPM beta | ||
|
||
on: | ||
workflow_dispatch | ||
|
||
jobs: | ||
publish: | ||
name: Publish NPM beta | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
- name: Set up JDK 17 | ||
uses: actions/setup-java@v4 | ||
with: | ||
java-version: 17 | ||
distribution: temurin | ||
cache: 'gradle' | ||
- name: Change wrapper permission | ||
run: chmod +x ./gradlew | ||
|
||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: 14.x | ||
|
||
- name: Publish NPMJS | ||
run: ./.github/workflows/scripts/publish-npm-beta.sh | ||
env: | ||
NPMJS_TOKEN: ${{ secrets.DHIS2_BOT_NPM_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,46 @@ | ||
name: Pull request | ||
|
||
on: [pull_request] | ||
on: | ||
pull_request | ||
|
||
jobs: | ||
unit-test: | ||
uses: ./.github/workflows/job-test.yml | ||
name: Run tests | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Set up JDK 17 | ||
uses: actions/setup-java@v4 | ||
with: | ||
java-version: 17 | ||
distribution: temurin | ||
cache: 'gradle' | ||
- name: Change wrapper permission | ||
run: chmod +x ./gradlew | ||
|
||
- name: Test | ||
run: ./gradlew clean allTests | ||
|
||
publish: | ||
name: Publish | ||
needs: unit-test | ||
if: ${{ !contains(github.event.pull_request.title, '[skip publish]') }} | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
- name: Set up JDK 17 | ||
uses: actions/setup-java@v4 | ||
with: | ||
java-version: 17 | ||
distribution: temurin | ||
cache: 'gradle' | ||
- name: Change wrapper permission | ||
run: chmod +x ./gradlew | ||
|
||
- name: Publish Maven Snapshot | ||
run: ./gradlew publishToSonatype | ||
env: | ||
OSSRH_USERNAME: ${{ secrets.SONATYPE_OSSRH_USERNAME }} | ||
OSSRH_PASSWORD: ${{ secrets.SONATYPE_OSSRH_PASSWORD }} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
set -x | ||
|
||
./gradlew packJsPackage | ||
./gradlew packJsPackage -PuseCommonJs | ||
|
||
cd build/packages/js || exit | ||
|
||
# Set authentication token for npmjs registry | ||
npm set //registry.npmjs.org/:_authToken="$NPMJS_TOKEN" | ||
|
||
# Set 'beta' suffix in the version starting with beta.0 | ||
sed -i -e 's/-SNAPSHOT"/-beta.0"/g' package.json | ||
|
||
# Try to upload the beta version. If it is not available, increase the beta number and try again. | ||
# Iterate a maximum of MAX_ITERATION times. | ||
n=1 | ||
MAX_ITERATIONS=30 | ||
while [ $n -le $MAX_ITERATIONS ]; do | ||
if ! output=$(npm publish --tag beta 2>&1); then | ||
if [[ "$output" == *"ERR! code E403"* ]]; then | ||
# This error code is likely to be thrown when the version already exists | ||
# Increase beta version number to try again | ||
npm version prerelease | ||
n=$(( n + 1 )) | ||
else | ||
exit 1 | ||
fi | ||
else | ||
# If upload is successful, exit | ||
exit 0 | ||
fi | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.