Skip to content

Commit

Permalink
Support publishing through Github Actions
Browse files Browse the repository at this point in the history
Add the necessary workflows to publish SNAPSHOT builds and stable releases.
  • Loading branch information
vRallev committed Sep 6, 2024
1 parent e0a386d commit fa5ea48
Show file tree
Hide file tree
Showing 5 changed files with 154 additions and 1 deletion.
50 changes: 50 additions & 0 deletions .github/workflows/publish-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Publish Release

on:
push:
tags:
- '*.*.*'

jobs:
publish-release:
runs-on: macos-latest
if: github.repository == 'amzn/kotlin-inject-anvil'
timeout-minutes: 25

steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: 21
- uses: gradle/actions/setup-gradle@v4

- name: Publish release
run: ./gradlew clean publish --no-build-cache --stacktrace --show-version
env:
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.SONATYPE_USERNAME }}
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.SONATYPE_PASSWORD }}
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.ARTIFACT_SIGNING_PRIVATE_KEY }}
ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.ARTIFACT_SIGNING_PRIVATE_KEY_PASSWORD }}

- name: Extract release notes
id: release_notes
uses: ffurrer2/extract-release-notes@v2

- name: Check if pre-release
id: prerelease
run: |
version=$(grep VERSION_NAME gradle.properties | cut -d'=' -f2)
if [[ $version == *"-beta"* ]]; then
echo "isPrerelease=true" >> $GITHUB_OUTPUT
else
echo "isPrerelease=false" >> $GITHUB_OUTPUT
fi
- name: Create release
uses: softprops/action-gh-release@v2
with:
body: ${{ steps.release_notes.outputs.release_notes }}
prerelease: ${{ steps.prerelease.outputs.isPrerelease }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
28 changes: 28 additions & 0 deletions .github/workflows/publish-snapshot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Publish Snapshot

on:
push:
branches:
- main

jobs:
publish-snapshot:
runs-on: macos-latest
if: github.repository == 'amzn/kotlin-inject-anvil'
timeout-minutes: 25

steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: 21
- uses: gradle/actions/setup-gradle@v4

- name: Publish snapshot
run: ./gradlew clean publish --no-build-cache --stacktrace --show-version
env:
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.SONATYPE_USERNAME }}
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.SONATYPE_PASSWORD }}
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.ARTIFACT_SIGNING_PRIVATE_KEY }}
ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.ARTIFACT_SIGNING_PRIVATE_KEY_PASSWORD }}
27 changes: 27 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Change Log

## [Unreleased]

### Added

### Changed

### Deprecated

### Removed

### Fixed

### Security

### Custom Code Generator

### Other Notes & Contributions


## [0.0.1] - 2024-09-05

- Initial release.

[Unreleased]: https://github.com/amzn/kotlin-inject-anvil/compare/0.0.1...HEAD
[0.0.1]: https://github.com/square/anvil/releases/tag/0.0.1
11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,15 @@ For details how to setup KSP itself for multiplatform projects see the
[official documentation](https://kotlinlang.org/docs/ksp-multiplatform.html). The setup for
`kotlin-inject` is described [here](https://github.com/evant/kotlin-inject).

#### Snapshot builds

To import snapshot builds use following repository:
```groovy
maven {
url 'https://aws.oss.sonatype.org/content/repositories/snapshots/'
}
```

## Usage

### Contributions
Expand Down Expand Up @@ -166,7 +175,7 @@ Note the `@ContributingAnnotation` marker, which is important for incremental co
multi-round support.

A custom KSP symbol processor uses this annotation as trigger and generates following code:
```
```kotlin
@ContributesTo
@SingleInAppScope
interface MyCustomComponent {
Expand Down
39 changes: 39 additions & 0 deletions RELEASING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Production Releases

1. Checkout `origin/main`.
2. Update the `CHANGELOG.md` file with the changes of this release (the format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
* Copy the template for the next unreleased version at the top.
* Delete unused section in the new release.
* Update the links at the bottom of the CHANGELOG.md file and don't forget to change the link for the unreleased version.
3. Update the version in `gradle.properties` and remove the `-SNAPSHOT` suffix.
4. Commit the changes and create a tag:
```
git commit -am "Releasing 0.1.0."
git tag 0.1.0
```
5. Update the version in `gradle.properties` and add the `-SNAPSHOT` suffix.
6. Commit the change:
```
git commit -am "Prepare next development version."
```
7. Push the two commits. This will start a Github action that publishes the release to Maven Central and creates a new release on Github.
```
git push && git push --tags
```

# Snapshot Releases

Snapshot releases are automatically created whenever a commit to the `main` branch is pushed.

# Manually uploading a release

Depending on the version in the `gradle.properties` file it will be either a production or snapshot release.
```
./gradlew clean publish --no-build-cache
```

# Installing in Maven Local

```
./gradlew publishToMavenLocal
```

0 comments on commit fa5ea48

Please sign in to comment.