Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
27 changes: 27 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: publish

on:
push:
tags:
- '**'

env:
GRADLE_OPTS: "-Dorg.gradle.jvmargs=-Xmx4g -Dorg.gradle.daemon=false -Dkotlin.incremental=false"

jobs:
publish:
runs-on: macos-15

steps:
- uses: actions/checkout@v5
- uses: actions/setup-java@v5
with:
distribution: 'zulu'
java-version-file: .github/workflows/.java-version

- run: ./gradlew publish
env:
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.SONATYPE_CENTRAL_USERNAME }}
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.SONATYPE_CENTRAL_PASSWORD }}
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.GPG_SECRET_KEY }}
ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.GPG_SECRET_PASSPHRASE }}
Comment on lines +13 to +27

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {contents: read}

Copilot Autofix

AI 7 months ago

To fix the problem, add a permissions block specifying the minimum necessary privileges for the workflow. In most publish workflows, unless you are using actions that write to issues, pull requests, or deployments, you typically only need read access to the repository contents. Place the following block after the name and before any jobs or steps:

permissions:
  contents: read

If future workflow changes require more privileges (e.g. writing releases or deployments), adjust accordingly.
Edit the .github/workflows/publish.yml file and insert the permissions block after the name: publish line and before the on: line.

Suggested changeset 1
.github/workflows/publish.yml

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml
--- a/.github/workflows/publish.yml
+++ b/.github/workflows/publish.yml
@@ -1,4 +1,6 @@
 name: publish
+permissions:
+  contents: read
 
 on:
   push:
EOF
@@ -1,4 +1,6 @@
name: publish
permissions:
contents: read

on:
push:
Copilot is powered by AI and may make mistakes. Always verify output.
26 changes: 3 additions & 23 deletions docs/releasing.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,6 @@
Releasing
=========

### Prerequisite: Sonatype (Maven Central) Account

Create an account on the [Sonatype issues site][sonatype_issues]. Ask an existing publisher to open
an issue requesting publishing permissions for `com.squareup` projects.


Cutting a Release
-----------------

1. Update `CHANGELOG.md`.

2. Set versions:
Expand All @@ -19,7 +10,7 @@ Cutting a Release
export NEXT_VERSION=X.Y.Z-SNAPSHOT
```

3. Update versions:
3. Update versions, tag the release, and prepare for the next release.

```
sed -i "" \
Expand All @@ -31,29 +22,18 @@ Cutting a Release
sed -i "" \
"s/\/com.squareup.okhttp3\/\([^\:]*\)\/[^\/]*\//\/com.squareup.okhttp3\/\1\/$RELEASE_VERSION\//g" \
`find . -name "README.md"`
```

4. Tag the release and push to GitHub.

```
git commit -am "Prepare for release $RELEASE_VERSION."
git tag -a parent-$RELEASE_VERSION -m "Version $RELEASE_VERSION"
git push && git push --tags
```

5. Wait for [GitHub Actions][github_actions] to start the publish job.

6. Prepare for ongoing development and push to GitHub.

```
sed -i "" \
sed -i "" \
"s/version = \".*\"/version = \"$NEXT_VERSION\"/g" \
build.gradle.kts
git commit -am "Prepare next development version."
git push
```

7. Confirm the [GitHub Actions][github_actions] publish job succeeded.
4. Wait for [GitHub Actions][github_actions] to build and promote the release.

[github_actions]: https://github.com/square/okhttp/actions
[sonatype_issues]: https://issues.sonatype.org/
Loading