Important
This repository is archived in favor of TelenorNorway/sh.tnn
Easily add GitHub Packages Repository
to your build.gradle(.kts?)
file with a standardized credential
configuration.
plugins {
kotlin("jvm") version "1.9.0"
id("no.ghpkg") version "0.1.2"
`maven-publish`
}
group = "org.example"
version = System.getenv().getOrDefault("VERSION", "UNVERSIONED")
repositories {
mavenCentral()
git.hub("octocat", "hello-world")
}
configure<PublishingExtension> {
repositories {
git.hub("example-org", "example-project")
}
publications {
register<MavenPublication>("gpr") {
from(components["kotlin"])
}
}
}
You need to create a CLASSIC personal access token.
Open a new terminal. Now you want to write the username and PAT to a shell
configuration file of your choice. Usually .profile
works everywhere. But
depending on your login shell you may also use .bashrc
, .zshrc
or .fishrc
.
You can run echo $SHELL
to figure out which shell configuration file you
should use.
Replace .profile
with your desired shell configuration file (optional).
Replace username
with your GitHub username.
Replace ...
with your GitHub PAT.
echo "export GITHUB_ACTOR=\"username\"" >> ~/.profile
echo "export GITHUB_TOKEN=\"...\"" >> ~/.profile
Press the WIN
button and search for environment
.
By now there should be a best match with
Edit the system environment variables
. Click it and a new windows will appear.
In the new Window click on Environment Variables.
When you click the button a new window will open. Click the New... button
inside the User variables for <username>
.
Write in Variable name: GITHUB_ACTOR
with your GitHub username.
Press OK. Do the same again with the GITHUB_TOKEN
.
Now press OK and Apply.
To verify if this is working or not you can restart IntelliJ IDEA, open any project, click edit run configurations and see if you can find GITHUB_ACTOR and GITHUB_TOKEN in the System Configurations.
If you don't see the variables in the system environment settings in the run options in IntelliJ you might've missed something. Feel free to ask for help.
permissions:
contents: read
packages: write
steps:
# ... prepare job ...
- name: Publish package
uses: gradle/gradle-build-action@749f47bda3e44aa060e82d7b3ef7e40d953bd629
with:
arguments: publish
env:
GITHUB_ACTOR: ${{ github.actor }}
GITHUB_TOKEN: ${{ github.token }}
VERSION: ${{ inputs.version }}