ci #29
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: ci | |
on: | |
# Allows you to run this workflow manually from the Actions tab | |
workflow_dispatch: | |
inputs: | |
proto_ref: | |
proto_sha: | |
push: | |
branches: | |
- main | |
- v* | |
# Publish `v1.2.3` tags as releases. | |
tags: | |
- v* | |
# Run tests for PRs | |
pull_request: | |
env: | |
VAULT_ADDR: https://vault.eng.aserto.com/ | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Info | |
run: echo "Using proto ${{ github.event.inputs.proto_ref }} with sha ${{ github.event.inputs.proto_sha }}" | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Setup Go | |
uses: actions/setup-go@v4 | |
with: | |
go-version: ${{ env.GO_VERSION }} | |
- name: Install dependencies, update proto and build | |
run: | | |
go run mage.go all | |
- name: Commit changes | |
if: github.event_name == 'workflow_dispatch' | |
uses: EndBug/add-and-commit@v9 | |
with: | |
default_author: github_actions | |
add: 'pom.xml src' | |
push: origin HEAD:main | |
release: | |
runs-on: ubuntu-latest | |
needs: build | |
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') | |
name: Release to maven central | |
steps: | |
- name: Read Configuration | |
uses: hashicorp/[email protected] | |
id: vault | |
with: | |
url: ${{ env.VAULT_ADDR }} | |
token: ${{ secrets.VAULT_TOKEN }} | |
secrets: | | |
kv/data/MavenCentral "USERNAME" | MAVEN_USERNAME; | |
kv/data/MavenCentral "PASSWORD" | MAVEN_PASSWORD; | |
kv/data/MavenCentral "GPG_PASSPHRASE" | MAVEN_GPG_PASSPHRASE; | |
kv/data/MavenCentral "PRIVATE_GPG_KEY" | GPG_PRIVATE_KEY; | |
- name: Setup Go | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Set up Java for publishing to Maven Central Repository | |
uses: actions/setup-java@v3 | |
with: | |
java-version: 8 | |
distribution: temurin | |
server-id: ossrh | |
server-username: MAVEN_USERNAME | |
server-password: MAVEN_PASSWORD | |
gpg-private-key: ${{ env.GPG_PRIVATE_KEY }} | |
gpg-passphrase: MAVEN_GPG_PASSPHRASE | |
- name: build artifact | |
run: mvn clean package | |
- name: Create release | |
uses: ncipollo/release-action@v1 | |
with: | |
allowUpdates: true | |
artifacts: "${{ github.workspace }}/target/*.jar" | |
token: ${{ secrets.GITHUB_TOKEN }} | |
- name: Publish to the Maven Central Repository | |
run: | | |
mvn \ | |
--no-transfer-progress \ | |
--batch-mode \ | |
-Pci-cd \ | |
deploy | |
- name: Bump to the next version | |
run: go run mage.go bump patch | |
- name: Commit changes | |
uses: EndBug/add-and-commit@v9 | |
with: | |
default_author: github_actions | |
message: 'Bump to next version' | |
add: 'pom.xml' | |
push: origin HEAD:main |