Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#2503 push SNAPSHOT Maven artifacts to github Packages #2525

Merged
merged 23 commits into from
Jun 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
bb56824
push artifacts to github Packages
icrc-fdeniger Apr 22, 2024
8293430
push artifacts to github Packages
icrc-fdeniger Apr 22, 2024
3e5fa81
Merge remote-tracking branch 'origin/master-deploy-repo' into master-…
icrc-fdeniger May 9, 2024
3aab8f7
try to use github.run_id
icrc-fdeniger May 9, 2024
dc5dca4
try to use github.run_id
icrc-fdeniger May 9, 2024
5e0dfa2
modify comments as suggests by MJ1998
icrc-fdeniger May 14, 2024
295b1df
Merge branch 'master' into master-deploy-repo
MJ1998 May 23, 2024
fe290b3
Merge remote-tracking branch 'origin/master-deploy-repo' into master-…
icrc-fdeniger May 30, 2024
484f4b5
Merge branch 'master' into master-deploy-repo
icrc-fdeniger May 31, 2024
02c1ab0
Merge remote-tracking branch 'origin/master-deploy-repo' into master-…
icrc-fdeniger Jun 6, 2024
ba30851
Merge branch 'master' into master-deploy-repo
icrc-fdeniger Jun 6, 2024
7b4b8c8
Merge remote-tracking branch 'origin/master-deploy-repo' into master-…
icrc-fdeniger Jun 6, 2024
6cc76ee
revert changes as required
icrc-fdeniger Jun 6, 2024
63a7acd
Merge branch 'master' into master-deploy-repo
jingtang10 Jun 7, 2024
4cb66c7
Merge branch 'master' into master-deploy-repo
jingtang10 Jun 8, 2024
557699a
Merge branch 'master' into master-deploy-repo
icrc-fdeniger Jun 14, 2024
a634dc4
revert changes as required
icrc-fdeniger Jun 14, 2024
e624971
revert changes as required
icrc-fdeniger Jun 14, 2024
c8e00bf
revert changes as required
icrc-fdeniger Jun 14, 2024
b8212e9
Format and language changes in the documentation
jingtang10 Jun 18, 2024
ad499cc
Merge branch 'master' into master-deploy-repo
icrc-fdeniger Jun 18, 2024
b7a2953
Merge branch 'master' into master-deploy-repo
jingtang10 Jun 18, 2024
15d6902
Merge branch 'master' into master-deploy-repo
icrc-fdeniger Jun 19, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ jobs:
permissions:
actions: read
contents: read
packages: write

strategy:
fail-fast: false
Expand All @@ -75,9 +76,21 @@ jobs:
- name: Check with Gradle
run: ./gradlew check --scan --full-stacktrace

- name: Publish Maven packages to GitHub Packages
if: ${{ github.event_name == 'push' }}
run: ./gradlew publish
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
REPOSITORY_URL: 'https://maven.pkg.github.com/google/android-fhir'
# Use SNAPSHOT Prefix to follow Maven convention
ARTIFACT_VERSION_SUFFIX: SNAPSHOT

- name: Release artifacts to local repo
run: ./gradlew publishReleasePublicationToCIRepository --scan
- name: Upload maven repo
env:
ARTIFACT_VERSION_SUFFIX: build_${{ github.run_id }}

- name: Upload artifact maven-repository.zip
uses: actions/upload-artifact@v4
with:
name: maven-repository
Expand Down
19 changes: 16 additions & 3 deletions buildSrc/src/main/kotlin/Releases.kt
jingtang10 marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -119,20 +119,33 @@ fun Project.publishArtifact(artifact: LibraryArtifact) {
licenses {
license {
name.set("The Apache License, Version 2.0")
url.set("http://www.apache.org/licenses/LICENSE-2.0.txt")
url.set("https://www.apache.org/licenses/LICENSE-2.0.txt")
}
}
}
repositories {
maven {
name = "CI"
url = uri("file://${rootProject.buildDir}/ci-repo")
url =
if (System.getenv("REPOSITORY_URL") != null) {
icrc-fdeniger marked this conversation as resolved.
Show resolved Hide resolved
// REPOSITORY_URL is defined in .github/workflows/build.yml
uri(System.getenv("REPOSITORY_URL"))
} else {
uri("file://${rootProject.buildDir}/ci-repo")
}
version =
if (project.providers.environmentVariable("GITHUB_ACTIONS").isPresent) {
"${artifact.version}-build_${System.getenv("GITHUB_RUN_ID")}"
// ARTIFACT_VERSION_SUFFIX is defined in .github/workflows/build.yml
"${artifact.version}-${System.getenv("ARTIFACT_VERSION_SUFFIX")}"
} else {
artifact.version
}
if (System.getenv("GITHUB_TOKEN") != null) {
credentials {
username = System.getenv("GITHUB_ACTOR")
password = System.getenv("GITHUB_TOKEN")
}
}
}
}
}
Expand Down
76 changes: 76 additions & 0 deletions docs/use/Snapshots.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# Snapshots

You can test the latest Android FHIR SDK libraries using the snapshot versions published on GitHub Packages.

They are unreleased versions of the library built from the `HEAD` of the main branch and have the `-SNAPSHOT` suffix in their version numbers.

They can be found here: https://github.com/google?tab=packages&repo_name=android-fhir

> :warning: The snapshots are for testing and development purposes only. They are not QA tested and not production ready. Do **NOT** use them in production.

# How to use SNAPSHOT artifacts

## Configure GitHub maven repositories in `build.gradle.kts`

Since these artifacts are deployed on GitHub Packages, a `username`/`GitHub token` pair is required as explained in [Authenticating to GitHub Packages](https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-apache-maven-registry#authenticating-to-github-packages). The token needs at least the `read:packages` scope.

This can be securely managed by placing the credentials in the `local.properties` file and loading them with `gradleLocalProperties`. With this approach, the file `build.gradle.kts` will look like:

```kotlin
import com.android.build.gradle.internal.cxx.configure.gradleLocalProperties

plugins {
...
}

android {
...
repositories{
maven {
url = uri("https://maven.pkg.github.com/google/android-fhir")
credentials {
username = gradleLocalProperties(rootDir).getProperty("gpr.user") ?: System.getenv("GPR_USER")
password = gradleLocalProperties(rootDir).getProperty("gpr.key") ?: System.getenv("GPR_KEY")
}
}
}
}

dependencies {
}
```

Notice the environment variables `GPR_USER`/`GPR_KEY` used in this file.

Then, the file `local.properties` will need to be created in the project root folder:

```dotenv
sdk.dir=<path to Android SDK>
gpr.user=<Your GitHub Account>
gpr.key=<A GitHub token>
```

## Declare dependencies

To include the snapshots in the dependencies of your app, modify `build.gradle.kts` in your app:

```kotlin
dependencies {
...
implementation("com.google.android.fhir:engine:<engine-version>-SNAPSHOT")
implementation("com.google.android.fhir:data-capture:<dc-version>-SNAPSHOT")
}
```

The versions `<...-version>` can be found in https://github.com/google?tab=packages&repo_name=android-fhir

## How SNAPSHOT versions are managed by Gradle

The complete documentation can be found in the section [Declaring a changing version](https://docs.gradle.org/current/userguide/dynamic_versions.html#sub:declaring_dependency_with_changing_version).

To summarize:
- By default, Gradle caches changing versions of dependencies for **24 hours**
- Dependency caching can be [controlled programmatically](https://docs.gradle.org/current/userguide/dynamic_versions.html#sec:controlling_dependency_caching_programmatically)
- The `--refresh-dependencies` option in command line tells Gradle to ignore all cached versions


1 change: 1 addition & 0 deletions mkdocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ nav:
- use/WFL/Compile-and-Execute-CQL.md
- use/Extensions.md
- API Doc: use/api.md
- Use Snapshots: use/Snapshots.md
- Contributors:
- Contributing: contrib/index.md
- Codespaces: contrib/codespaces.md
Expand Down
Loading