Skip to content

Commit 9d21e8a

Browse files
kridaiclaude
andcommitted
chore: migrate publishing to Maven Central and harden GitHub Actions
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
1 parent 04d1d3a commit 9d21e8a

5 files changed

Lines changed: 79 additions & 110 deletions

File tree

‎.github/dependabot.yml‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "github-actions"
4+
directory: "/"
5+
schedule:
6+
interval: "weekly"
7+
- package-ecosystem: "maven"
8+
directory: "/"
9+
schedule:
10+
interval: "weekly"

‎.github/workflows/pr-lint.yml‎

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,22 @@ on:
33
pull_request_target:
44
types: [ opened, edited, synchronize, reopened ]
55

6+
permissions:
7+
contents: read
8+
pull-requests: read
9+
610
jobs:
711
validate:
812
name: Validate title
9-
runs-on: ubuntu-latest
13+
runs-on: ubuntu-x64
1014
steps:
11-
- uses: amannn/action-semantic-pull-request@v4
15+
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
16+
- uses: twilio/sdk-actions/semantic-pr-title@09631bfa50f14d276170d45bc4f49a80da201cc6 # main @ 09631bf — sdk-actions#10; repin to the v1.1.0 tag once cut
1217
with:
13-
types: chore docs fix feat test misc
14-
env:
15-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
18+
types: |
19+
chore
20+
docs
21+
fix
22+
feat
23+
misc
24+
test

‎.github/workflows/test-and-deploy.yml‎

Lines changed: 41 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,20 @@ on:
1313
jobs:
1414
test:
1515
name: Test
16-
runs-on: ubuntu-latest
16+
runs-on: ubuntu-x64
17+
if: github.repository_owner == 'sendgrid'
1718
timeout-minutes: 20
19+
permissions:
20+
contents: read
1821
strategy:
1922
matrix:
2023
java: [ 8, 11, 17 ]
2124
steps:
2225
- name: Checkout smtpapi-java
23-
uses: actions/checkout@v2
26+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
2427

2528
- name: Set up Java
26-
uses: actions/setup-java@v2
29+
uses: actions/setup-java@c5195efecf7bdfc987ee8bae7a71cb8b11521c00 # v4.7.1
2730
with:
2831
distribution: 'temurin'
2932
java-version: ${{ matrix.java }}
@@ -37,19 +40,24 @@ jobs:
3740

3841
deploy:
3942
name: Deploy
40-
if: success() && github.ref_type == 'tag'
43+
if: success() && github.ref_type == 'tag' && github.repository_owner == 'sendgrid'
4144
needs: [ test ]
42-
runs-on: ubuntu-latest
45+
runs-on: ubuntu-x64
46+
permissions:
47+
contents: write
4348
steps:
4449
- name: Checkout smtpapi-java
45-
uses: actions/checkout@v2
50+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
51+
with:
52+
# The release action verifies refs/tags/<tag> in the local clone.
53+
fetch-depth: 0
4654

4755
- name: Set up Sonatype Maven
48-
uses: actions/setup-java@v2
56+
uses: actions/setup-java@c5195efecf7bdfc987ee8bae7a71cb8b11521c00 # v4.7.1
4957
with:
50-
java-version: 8
58+
java-version: '8'
5159
distribution: temurin
52-
server-id: ossrh
60+
server-id: central
5361
server-username: MAVEN_USERNAME
5462
server-password: MAVEN_PASSWORD
5563
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }}
@@ -59,12 +67,11 @@ jobs:
5967
run: make install
6068

6169
- name: Create GitHub Release
62-
uses: sendgrid/dx-automator/actions/release@main
70+
uses: twilio/sdk-actions/github-release@9b1c3222c9ffe38aadedb11c5b9f5a172b5e9951 # v1
6371
with:
6472
assets: smtpapi-java.jar
65-
footer: '**[Maven](https://mvnrepository.com/artifact/com.sendgrid/smtpapi-java/${version})**'
66-
env:
67-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
73+
changelog-file: CHANGELOG.md
74+
footer: '**[Maven](https://mvnrepository.com/artifact/com.sendgrid/smtpapi-java/${{ github.ref_name }})**'
6875

6976
- name: Publish to Maven
7077
env:
@@ -73,25 +80,25 @@ jobs:
7380
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
7481
run: mvn clean deploy -DskipTests=true -B -U -Prelease
7582

76-
- name: Submit metric to Datadog
77-
uses: sendgrid/dx-automator/actions/datadog-release-metric@main
78-
env:
79-
DD_API_KEY: ${{ secrets.DATADOG_API_KEY }}
83+
# - name: Submit metric to Datadog
84+
# uses: sendgrid/dx-automator/actions/datadog-release-metric@08b601b726671445abc798ed59881766ec8fefc6 # main
85+
# env:
86+
# DD_API_KEY: ${{ secrets.DATADOG_API_KEY }}
8087

81-
notify-on-failure:
82-
name: Slack notify on failure
83-
if: failure() && github.event_name != 'pull_request' && (github.ref == 'refs/heads/main' || github.ref_type == 'tag')
84-
needs: [ test, deploy ]
85-
runs-on: ubuntu-latest
86-
steps:
87-
- uses: rtCamp/action-slack-notify@v2
88-
env:
89-
SLACK_COLOR: failure
90-
SLACK_ICON_EMOJI: ':github:'
91-
SLACK_MESSAGE: ${{ format('Test *{0}*, Deploy *{1}*, {2}/{3}/actions/runs/{4}', needs.test.result, needs.deploy.result, github.server_url, github.repository, github.run_id) }}
92-
SLACK_TITLE: Action Failure - ${{ github.repository }}
93-
SLACK_USERNAME: GitHub Actions
94-
SLACK_MSG_AUTHOR: twilio-dx
95-
SLACK_FOOTER: Posted automatically using GitHub Actions
96-
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
97-
MSG_MINIMAL: true
88+
# notify-on-failure:
89+
# name: Slack notify on failure
90+
# if: failure() && github.event_name != 'pull_request' && (github.ref == 'refs/heads/main' || github.ref_type == 'tag')
91+
# needs: [ test, deploy ]
92+
# runs-on: ubuntu-x64
93+
# steps:
94+
# - uses: rtCamp/action-slack-notify@e31e87e03dd19038e411e38ae27cbad084a90661 # v2.3.3
95+
# env:
96+
# SLACK_COLOR: failure
97+
# SLACK_ICON_EMOJI: ':github:'
98+
# SLACK_MESSAGE: ${{ format('Test *{0}*, Deploy *{1}*, {2}/{3}/actions/runs/{4}', needs.test.result, needs.deploy.result, github.server_url, github.repository, github.run_id) }}
99+
# SLACK_TITLE: Action Failure - ${{ github.repository }}
100+
# SLACK_USERNAME: GitHub Actions
101+
# SLACK_MSG_AUTHOR: twilio-dx
102+
# SLACK_FOOTER: Posted automatically using GitHub Actions
103+
# SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
104+
# MSG_MINIMAL: true

‎.github/workflows/update-dependencies.yml‎

Lines changed: 0 additions & 60 deletions
This file was deleted.

‎pom.xml‎

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
33
<modelVersion>4.0.0</modelVersion>
4-
<parent>
5-
<groupId>org.sonatype.oss</groupId>
6-
<artifactId>oss-parent</artifactId>
7-
<version>7</version>
8-
</parent>
94
<groupId>com.sendgrid</groupId>
105
<artifactId>smtpapi-java</artifactId>
116
<packaging>jar</packaging>
@@ -20,6 +15,15 @@
2015
<distribution>repo</distribution>
2116
</license>
2217
</licenses>
18+
<developers>
19+
<developer>
20+
<id>api</id>
21+
<name>Twilio API</name>
22+
<email>api@twilio.com</email>
23+
<organization>Twilio, Inc.</organization>
24+
<organizationUrl>https://www.twilio.com</organizationUrl>
25+
</developer>
26+
</developers>
2327
<scm>
2428
<url>scm:git@github.com:sendgrid/smtpapi-java.git</url>
2529
<connection>scm:git@github.com:sendgrid/smtpapi-java.git</connection>
@@ -37,14 +41,13 @@
3741
<build>
3842
<plugins>
3943
<plugin>
40-
<groupId>org.sonatype.plugins</groupId>
41-
<artifactId>nexus-staging-maven-plugin</artifactId>
42-
<version>1.6.8</version>
44+
<groupId>org.sonatype.central</groupId>
45+
<artifactId>central-publishing-maven-plugin</artifactId>
46+
<version>0.8.0</version>
4347
<extensions>true</extensions>
4448
<configuration>
45-
<serverId>ossrh</serverId>
46-
<nexusUrl>https://oss.sonatype.org/</nexusUrl>
47-
<autoReleaseAfterClose>true</autoReleaseAfterClose>
49+
<publishingServerId>central</publishingServerId>
50+
<autoPublish>true</autoPublish>
4851
</configuration>
4952
</plugin>
5053
<plugin>

0 commit comments

Comments
 (0)