Upload Release Assets #31
Workflow file for this run
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: Upload Release Assets | |
on: | |
release: | |
types: [ prereleased, released ] | |
workflow_dispatch: | |
jobs: | |
upload-release-assets: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
# Get the version from the commit. This will depend on the trigger of the workflow | |
# If the trigger is release, the version will be the tag on the commit. | |
# If the trigger is a workflow_dispatch, the version will be the branch name, which is | |
# not really useful. | |
- id: get_version | |
uses: battila7/get-version-action@v2 | |
- name: printVersion | |
run: echo "The version extracted from github.ref is ${{ steps.get_version.outputs.version }}" | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: '17' | |
distribution: 'zulu' | |
- name: Generate CLI jar | |
if: github.event_name == 'release' | |
run: ./gradlew shadowJar | |
- name: Upload JAR Asset | |
if: github.event_name == 'release' | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ github.event.release.upload_url }} | |
asset_path: ./cli/build/libs/gtfs-validator-${{ steps.get_version.outputs.version-without-v }}-cli.jar | |
asset_name: gtfs-validator-${{ steps.get_version.outputs.version-without-v }}-cli.jar | |
asset_content_type: application/java-archive | |
- name: Generate rules.json | |
if: github.event_name == 'release' | |
run: ./gradlew webClientRulesJSON | |
- name: Upload rules.json asset | |
if: github.event_name == 'release' | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ github.event.release.upload_url }} | |
asset_path: ./web/client/static/rules.json | |
asset_name: rules.json | |
asset_content_type: application/json | |
- name: Generate JavaDocs | |
if: github.event_name == 'release' | |
run: ./gradlew aggregateJavadoc | |
- name: Zip JavaDocs | |
if: github.event_name == 'release' | |
run: zip -r javadocs.zip build/docs/aggregateJavadoc | |
- name: Upload zipped Javadocs | |
if: github.event_name == 'release' | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ github.event.release.upload_url }} | |
asset_path: ./javadocs.zip | |
asset_name: javadocs.zip | |
asset_content_type: application/zip | |
# The following steps will publish artifacts to a sonatype staging repo with the aim of promoting them to maven central | |
# Pretty much everything is done through gradle. | |
# The version used will be according to the axion-release-plugin, meaning it will take a tag if present. | |
# The tag should follow semantic versioning, e.g. v1.2.3. There could be a suffix, e.g. v1.2.3-TEST | |
# gradle will build, sign then upload artifacts to a Sonatype staging repo. | |
# See https://s01.oss.sonatype.org for accessing these repos. | |
# At this point it should manually be closed, which will trigger acceptance tests for maven central (but not transfer yet) | |
# Once closed, the repo is available for testing. | |
# After testing, it can be manually promoted on the sonatype site, which will then publish to maven central. | |
# Note than once in maven central a release cannot be removed or altered. | |
- name: Load secrets from 1Password | |
id: onepw_secrets | |
uses: ./.github/actions/extract-1password-secret | |
with: | |
OP_SERVICE_ACCOUNT_TOKEN: ${{ secrets.OP_SERVICE_ACCOUNT_TOKEN }} # This is required to connect to the vault in our 1Password account. | |
VARIABLES_TO_EXTRACT: 'MAVEN_GPG_PASSPHRASE, MAVEN_GPG_PRIVATE_KEY, SONATYPE_TOKEN_USERNAME, SONATYPE_TOKEN_PASSWORD' | |
ONE_PASSWORD_SECRET_REFERENCES: ${{ vars.ONE_PASSWORD_SECRET_REFERENCES }} | |
- name: Build and Publish to Sonatype | |
run: | | |
# The gradle java verifying plugin does not work with java 17. | |
# Don't verify since it has already been done when the PR was created. | |
./gradlew publish --rerun-tasks -x verifyGoogleJavaFormat | |