Skip to content
This repository has been archived by the owner on Jun 29, 2023. It is now read-only.

Commit

Permalink
update workflows for release + versioning
Browse files Browse the repository at this point in the history
  • Loading branch information
mike-audi committed Apr 1, 2023
1 parent 4e05c24 commit d73f7bf
Show file tree
Hide file tree
Showing 4 changed files with 126 additions and 69 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ jobs:
with:
fetch-depth: 1

- name: Set up JDK 19
- name: Set up JDK
uses: actions/setup-java@v3
with:
java-version: '19'
java-version: '20'
distribution: 'zulu'

- name: Initialize CodeQL
Expand Down
87 changes: 22 additions & 65 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,69 +7,16 @@ on:
types:
- closed

permissions:
contents: write
id-token: write

# Cancel any active builds when new commits are pushed
concurrency:
group: ${{ github.ref }}-${{ github.workflow }}
cancel-in-progress: true

jobs:
bump_and_tag:
if: github.event.pull_request.merged == true && startsWith(github.head_ref, 'release/')
runs-on: ubuntu-latest
environment: Production
services:
postgres:
image: postgres:14.5
env:
POSTGRES_USER: tester
POSTGRES_PASSWORD: pgtestpw
POSTGRES_DB: l0_storage
POSTGRES_PORT: 5432
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Set up JDK 19
uses: actions/setup-java@v3
with:
java-version: '19'
distribution: 'zulu'

- name: Install CLI
uses: dopplerhq/cli-action@v2

- name: Install PostgreSQL client
run: |
sudo apt-get update
sudo apt-get install --yes postgresql-client
- name: Create Tables
run: psql -h localhost -d l0_storage -U tester -f database/create_tables.sql
env:
PGPASSWORD: pgtestpw

- name: Maven Package
run: doppler run -c tst -- mvn clean package
env:
DOPPLER_TOKEN: ${{ secrets.DOPPLER_ST }}

- name: Bump Version
id: bump-version
uses: RichardInnocent/[email protected]
with:
access-token: ${{ secrets.github_token }}
version-prefix:

outputs:
version: ${{ steps.bump-version.outputs.new-version }}
test_and_push:
runs-on: ubuntu-latest
needs: bump_and_tag
Expand All @@ -94,10 +41,10 @@ jobs:
- name: Checkout
uses: actions/checkout@v3

- name: Set up JDK 19
- name: Set up JDK
uses: actions/setup-java@v3
with:
java-version: '19'
java-version: '20'
distribution: 'zulu'

- name: Install CLI
Expand Down Expand Up @@ -126,20 +73,28 @@ jobs:
- name: Registry login
run: doctl registry login --expiry-seconds 600

- name: Mvn project version
id: version
run: echo "version=$(mvn -q -Dexec.executable=echo -Dexec.args='${project.version}' --non-recursive exec:exec)" >> $GITHUB_OUTPUT

- name: Build and push
uses: docker/build-push-action@v4
with:
context: .
file: Dockerfile
push: true
tags: |
registry.digitalocean.com/tiki/l0-storage:${{ needs.bump_and_tag.outputs.version }}
registry.digitalocean.com/tiki/l0-storage:${{ steps.version.outputs.version }}
registry.digitalocean.com/tiki/l0-storage:latest
build-args: |
JAR_FILE=target/*.jar
outputs:
version: ${{ steps.version.outputs.version }}

deploy_to_infra:
runs-on: ubuntu-latest
needs: [ bump_and_tag, test_and_push ]
needs: [ test_and_push ]
environment: Production
steps:
- name: Checkout
Expand Down Expand Up @@ -171,6 +126,7 @@ jobs:
id: apply
run: terraform apply -auto-approve
working-directory: infra

sentry_release:
runs-on: ubuntu-latest
needs: deploy_to_infra
Expand All @@ -189,9 +145,10 @@ jobs:
environment: public
ignore_missing: true
ignore_empty: true

publish_docs:
runs-on: ubuntu-latest
needs: [ sentry_release, bump_and_tag ]
needs: [ sentry_release, test_and_push ]
environment: Production
steps:
- name: Checkout
Expand All @@ -200,9 +157,9 @@ jobs:
- name: OpenApi
uses: readmeio/[email protected]
with:
rdme: openapi docs/openapi.yaml --key=${{ secrets.README_API_KEY }} --id=6379efc05c98fc002512b213
rdme: openapi openapi.yaml --key=${{ secrets.README_API_KEY }} --id=6379efc05c98fc002512b213

- name: Release
uses: softprops/action-gh-release@v1
uses: ncipollo/release-action@v1
with:
tag_name: ${{ needs.bump_and_tag.outputs.version }}
tag: ${{ needs.test_and_push.outputs.version }}
4 changes: 2 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ jobs:
- name: Checkout
uses: actions/checkout@v3

- name: Set up JDK 19
- name: Set up JDK
uses: actions/setup-java@v3
with:
java-version: '19'
java-version: '20'
distribution: 'zulu'

- name: Install CLI
Expand Down
100 changes: 100 additions & 0 deletions .github/workflows/version.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
name: Version

on:
pull_request:
branches:
- main

# Cancel any active builds when new commits are pushed
concurrency:
group: ${{ github.ref }}-${{ github.workflow }}
cancel-in-progress: true

jobs:
Version:
if: startsWith(github.head_ref, 'release/')
runs-on: ubuntu-latest
services:
postgres:
image: postgres:14.5
env:
POSTGRES_USER: tester
POSTGRES_PASSWORD: pgtestpw
POSTGRES_DB: l0_storage
POSTGRES_PORT: 5432
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Set up JDK
uses: actions/setup-java@v3
with:
java-version: '20'
distribution: 'zulu'

- name: Checkout PR
id: getpr
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh pr checkout ${{ github.event.pull_request.number }}
export PR_BRANCH=$(git branch --show-current)
echo "branch=$PR_BRANCH" >> $GITHUB_OUTPUT
- name: Get Version
id: semver
uses: ietf-tools/semver-action@v1
with:
token: ${{ github.token }}
branch: ${{ steps.getpr.outputs.branch }}

- name: Set Version
run: |
sed -i '0,/<version>*.*.*<\/version>/s//<version>${{ steps.semver.outputs.nextStrict }}<\/version>/' pom.xml
- name: Set up JDK
uses: actions/setup-java@v3
with:
java-version: '20'
distribution: 'zulu'

- name: Install CLI
uses: dopplerhq/cli-action@v2

- name: Install PostgreSQL client
run: |
sudo apt-get update
sudo apt-get install --yes postgresql-client
- name: Create Tables
run: psql -h localhost -d l0_storage -U tester -f database/create_tables.sql
env:
PGPASSWORD: pgtestpw

- name: OAS3
run: doppler run -c tst -- mvn clean verify
env:
DOPPLER_TOKEN: ${{ secrets.DOPPLER_ST }}

- name: Commit Changes
continue-on-error: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git config --global user.email "[email protected]"
git config --global user.name "GH Action"
git add pom.xml
git add openapi.yaml
git commit -m 'version bump'
git push
outputs:
version: ${{ steps.semver.outputs.nextStrict }}

0 comments on commit d73f7bf

Please sign in to comment.