-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,8 @@ | ||
# The following workflow provides an opinionated template you can customize for your own needs. | ||
# | ||
# If you are not an Octopus user, the "Push to Octopus", "Generate Octopus Deploy build information", | ||
# and "Create Octopus Release" steps can be safely deleted. | ||
# | ||
# To configure Octopus, set the OCTOPUS_API_TOKEN secret to the Octopus API key, and | ||
# set the OCTOPUS_SERVER_URL secret to the Octopus URL. | ||
# | ||
|
@@ -8,129 +11,134 @@ | |
# | ||
# Get a trial Octopus instance from https://octopus.com/start | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v1 | ||
with: | ||
fetch-depth: '0' | ||
- name: Install GitVersion | ||
uses: gittools/actions/gitversion/[email protected] | ||
with: | ||
versionSpec: 5.x | ||
- id: determine_version | ||
name: Determine Version | ||
uses: gittools/actions/gitversion/[email protected] | ||
with: | ||
additionalArguments: /overrideconfig mode=Mainline | ||
- name: Install Octopus Deploy CLI | ||
uses: OctopusDeploy/[email protected] | ||
with: | ||
version: latest | ||
- name: Set up JDK 1.17 | ||
uses: actions/setup-java@v2 | ||
with: | ||
java-version: '17' | ||
distribution: adopt | ||
- name: List Dependencies | ||
run: gradle dependencies --console=plain > dependencies.txt | ||
shell: bash | ||
- name: Collect Dependencies | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: Dependencies | ||
path: dependencies.txt | ||
- name: Test | ||
run: gradle check --console=plain || true | ||
shell: bash | ||
- if: always() | ||
name: Report | ||
uses: dorny/test-reporter@v1 | ||
with: | ||
name: Gradle Tests | ||
path: build/test-results/**/*.xml | ||
reporter: java-junit | ||
fail-on-error: 'false' | ||
- name: Package | ||
run: gradle clean assemble --console=plain | ||
shell: bash | ||
- id: get_artifact | ||
name: Get Artifact Path | ||
run: |- | ||
# Find the largest WAR or JAR, and assume that was what we intended to build. | ||
echo "::set-output name=artifact::$(find build -type f \( -iname \*.jar -o -iname \*.war \) -printf "%p\n" | sort -n | head -1)" | ||
shell: bash | ||
- id: get_artifact_name | ||
name: Get Artifact Name | ||
run: |- | ||
# Get the filename without a path | ||
path="${{ steps.get_artifact.outputs.artifact }}" | ||
echo "::set-output name=artifact::${path##*/}" | ||
shell: bash | ||
- name: Tag Release | ||
uses: mathieudutour/[email protected] | ||
with: | ||
custom_tag: ${{ steps.determine_version.outputs.semVer }} | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
- env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
id: create_release | ||
name: Create Release | ||
uses: actions/create-release@v1 | ||
with: | ||
tag_name: ${{ steps.determine_version.outputs.semVer }}+run${{ github.run_number }}-attempt${{ github.run_attempt }} | ||
release_name: Release ${{ steps.determine_version.outputs.semVer }} Run ${{ github.run_number }} Attempt ${{ github.run_attempt }} | ||
draft: 'false' | ||
prerelease: 'false' | ||
- env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
name: Upload Release Asset | ||
uses: actions/upload-release-asset@v1 | ||
with: | ||
upload_url: ${{ steps.create_release.outputs.upload_url }} | ||
asset_path: ${{ steps.get_artifact.outputs.artifact }} | ||
asset_name: ${{ steps.get_artifact_name.outputs.artifact }} | ||
asset_content_type: application/octet-stream | ||
- id: get_octopus_artifact | ||
name: Create Octopus Artifact | ||
run: | | ||
# Octopus expects artifacts to have a specific file format | ||
file="${{ steps.get_artifact.outputs.artifact }}" | ||
extension="${file##*.}" | ||
octofile="RandomQuotes-Java.${{ steps.determine_version.outputs.semVer }}.${extension}" | ||
cp ${file} ${octofile} | ||
echo "::set-output name=artifact::${octofile}" | ||
# The version used when creating a release is the package id, colon, and version | ||
octoversion="RandomQuotes-Java:${{ steps.determine_version.outputs.semVer }}" | ||
echo "::set-output name=octoversion::${octoversion}" | ||
shell: bash | ||
- name: Push to Octopus | ||
uses: OctopusDeploy/[email protected] | ||
with: | ||
api_key: ${{ secrets.OCTOPUS_API_TOKEN }} | ||
packages: ${{ steps.get_octopus_artifact.outputs.artifact }} | ||
server: ${{ secrets.OCTOPUS_SERVER_URL }} | ||
overwrite_mode: OverwriteExisting | ||
- name: Generate Octopus Deploy build information | ||
uses: xo-energy/[email protected] | ||
with: | ||
octopus_api_key: ${{ secrets.OCTOPUS_API_TOKEN }} | ||
octopus_project: RandomQuotes-Java | ||
octopus_server: ${{ secrets.OCTOPUS_SERVER_URL }} | ||
push_version: ${{ steps.determine_version.outputs.semVer }} | ||
push_package_ids: RandomQuotes-Java | ||
push_overwrite_mode: OverwriteExisting | ||
output_path: octopus | ||
- name: Create Octopus Release | ||
uses: OctopusDeploy/[email protected] | ||
with: | ||
api_key: ${{ secrets.OCTOPUS_API_TOKEN }} | ||
project: RandomQuotes-Java | ||
server: ${{ secrets.OCTOPUS_SERVER_URL }} | ||
deploy_to: Dev | ||
packages: ${{ steps.get_octopus_artifact.outputs.octoversion }} | ||
name: Java Gradle Build | ||
'on': | ||
workflow_dispatch: {} | ||
push: {} | ||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: '0' | ||
- name: Install GitVersion | ||
uses: gittools/actions/gitversion/[email protected] | ||
with: | ||
versionSpec: 5.x | ||
- id: determine_version | ||
name: Determine Version | ||
uses: gittools/actions/gitversion/[email protected] | ||
with: | ||
additionalArguments: /overrideconfig mode=Mainline | ||
- name: Install Octopus Deploy CLI | ||
uses: OctopusDeploy/install-octopus-cli-action@v1 | ||
with: | ||
version: latest | ||
- name: Set up JDK 1.17 | ||
uses: actions/setup-java@v2 | ||
with: | ||
java-version: '17' | ||
distribution: adopt | ||
- name: List Dependencies | ||
run: ./gradlew dependencies --console=plain > dependencies.txt | ||
shell: bash | ||
- name: Collect Dependencies | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: Dependencies | ||
path: dependencies.txt | ||
- name: Test | ||
run: ./gradlew check --console=plain | ||
shell: bash | ||
- if: always() | ||
name: Report | ||
uses: dorny/test-reporter@v1 | ||
with: | ||
name: Gradle Tests | ||
path: build/test-results/**/*.xml | ||
reporter: java-junit | ||
fail-on-error: 'false' | ||
- name: Package | ||
run: ./gradlew clean assemble --console=plain | ||
shell: bash | ||
- id: get_artifact | ||
name: Get Artifact Path | ||
run: |- | ||
# Find the largest WAR or JAR, and assume that was what we intended to build. | ||
echo "::set-output name=artifact::$(find build -type f \( -iname \*.jar -o -iname \*.war \) -printf "%p\n" | sort -n | head -1)" | ||
shell: bash | ||
- id: get_artifact_name | ||
name: Get Artifact Name | ||
run: |- | ||
# Get the filename without a path | ||
path="${{ steps.get_artifact.outputs.artifact }}" | ||
echo "::set-output name=artifact::${path##*/}" | ||
shell: bash | ||
- name: Tag Release | ||
uses: mathieudutour/[email protected] | ||
with: | ||
custom_tag: ${{ steps.determine_version.outputs.semVer }} | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
- id: create_release | ||
name: Create Release | ||
uses: actions/create-release@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
tag_name: ${{ steps.determine_version.outputs.semVer }}+run${{ github.run_number }}-attempt${{ github.run_attempt }} | ||
release_name: Release ${{ steps.determine_version.outputs.semVer }} Run ${{ github.run_number }} Attempt ${{ github.run_attempt }} | ||
draft: 'false' | ||
prerelease: 'false' | ||
- name: Upload Release Asset | ||
uses: actions/upload-release-asset@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
upload_url: ${{ steps.create_release.outputs.upload_url }} | ||
asset_path: ${{ steps.get_artifact.outputs.artifact }} | ||
asset_name: ${{ steps.get_artifact_name.outputs.artifact }} | ||
asset_content_type: application/octet-stream | ||
- id: get_octopus_artifact | ||
name: Create Octopus Artifact | ||
run: | | ||
# Octopus expects artifacts to have a specific file format | ||
file="${{ steps.get_artifact.outputs.artifact }}" | ||
extension="${file##*.}" | ||
octofile="SampleGradleProject-SpringBoot.${{ steps.determine_version.outputs.semVer }}.${extension}" | ||
cp ${file} ${octofile} | ||
echo "::set-output name=artifact::${octofile}" | ||
# The version used when creating a release is the package id, colon, and version | ||
octoversion="SampleGradleProject-SpringBoot:${{ steps.determine_version.outputs.semVer }}" | ||
echo "::set-output name=octoversion::${octoversion}" | ||
shell: bash | ||
- name: Push packages to Octopus Deploy | ||
uses: OctopusDeploy/push-package-action@v2 | ||
env: | ||
OCTOPUS_API_KEY: ${{ secrets.OCTOPUS_API_TOKEN }} | ||
OCTOPUS_CLI_SERVER: ${{ secrets.OCTOPUS_SERVER_URL }} | ||
with: | ||
packages: ${{ steps.get_octopus_artifact.outputs.artifact }} | ||
overwrite_mode: OverwriteExisting | ||
- name: Generate Octopus Deploy build information | ||
uses: OctopusDeploy/push-build-information-action@v3 | ||
env: | ||
OCTOPUS_API_KEY: ${{ secrets.OCTOPUS_API_TOKEN }} | ||
OCTOPUS_URL: ${{ secrets.OCTOPUS_SERVER_URL }} | ||
OCTOPUS_SPACE: ${{ secrets.OCTOPUS_SPACE }} | ||
with: | ||
version: ${{ steps.determine_version.outputs.semVer }} | ||
packages: SampleGradleProject-SpringBoot | ||
overwrite_mode: OverwriteExisting | ||
- name: Create Octopus Release | ||
uses: OctopusDeploy/create-release-action@v1 | ||
with: | ||
api_key: ${{ secrets.OCTOPUS_API_TOKEN }} | ||
project: SampleGradleProject-SpringBoot | ||
server: ${{ secrets.OCTOPUS_SERVER_URL }} | ||
deploy_to: Development | ||
packages: ${{ steps.get_octopus_artifact.outputs.octoversion }} | ||
permissions: | ||
id-token: write | ||
checks: write | ||
contents: write |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
This file was deleted.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.