Skip to content

Commit

Permalink
Set up Publish action in Github Actions (#624)
Browse files Browse the repository at this point in the history
  • Loading branch information
prashanDYDX authored Sep 9, 2024
1 parent 2c11fd4 commit ac7a267
Show file tree
Hide file tree
Showing 6 changed files with 84 additions and 200 deletions.
122 changes: 0 additions & 122 deletions .github/workflows/bump_version.yml

This file was deleted.

63 changes: 0 additions & 63 deletions .github/workflows/bump_version_on_main.yml

This file was deleted.

82 changes: 82 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
name: Publish packages

on:
push:
branches:
- main
workflow_dispatch:


jobs:
check-version:
name: Check if version has changed
runs-on: ubuntu-latest
outputs:
new_version: ${{ steps.check.outputs.new_version }}
steps:
- uses: actions/checkout@v4
- id: check
run: |
currentVersion=$(grep '^version = ' build.gradle.kts | sed 's/version = //g' | tr -d '"')
echo "Current version is $currentVersion"
previousVersion=$(git show HEAD^:build.gradle.kts | grep '^version = ' | sed 's/version = //g' | tr -d '"')
echo "Previous version is $previousVersion"
if [ "$currentVersion" != "$previousVersion" ]; then
echo "Version changed -- continuing workflow"
echo "new_version=$currentVersion" >> "$GITHUB_OUTPUT"
else
echo "Version not changed -- aborting workflow"
exit 1
fi
create-tag:
runs-on: ubuntu-latest
needs: check-version
permissions:
contents: write
steps:
- uses: jaywcjlove/create-tag-action@v2
with:
version: ${{ needs.check-version.outputs.new_version }}
release: true
test: '^v\d+\.\d+\.\d+$'

publish-jvm:
name: Publish JVM Package
runs-on: ubuntu-latest
needs: check-version
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
distribution: 'adopt'
java-version: '17'
- uses: gradle/actions/setup-gradle@v4

- name: Publish to Github Packages
run: ./gradlew publishJvmPublicationToGitHubPackagesRepository

publish-js:
name: Publish JS Package
runs-on: ubuntu-latest
needs: check-version
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
distribution: 'adopt'
java-version: '17'
- uses: gradle/actions/setup-gradle@v4

- name: Publish to NPM
run: |
./gradlew assembleJsPackage
cp "LICENSE" "build/packages/js/LICENSE"
./gradlew publishJsPackageToNpmjsRegistry
env:
npm_token: ${{ secrets.NPM_TOKEN }}



6 changes: 2 additions & 4 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -222,13 +222,11 @@ npmPublish {
publishing {
repositories {
maven {
val github_username = System.getenv("github_username")
val github_token = System.getenv("github_token")
name = "GitHubPackages"
url = uri("https://maven.pkg.github.com/dydxprotocol/v4-abacus")
credentials {
username = github_username
password = github_token
username = System.getenv("GITHUB_ACTOR")
password = System.getenv("GITHUB_TOKEN")
}
}
}
Expand Down
4 changes: 0 additions & 4 deletions publish_android.sh

This file was deleted.

7 changes: 0 additions & 7 deletions publish_js.sh

This file was deleted.

0 comments on commit ac7a267

Please sign in to comment.