Skip to content

Commit

Permalink
New Release Workflow (AppliedEnergistics#6677)
Browse files Browse the repository at this point in the history
* New Release Workflow
* Remove the ever-changing timestamp from the Jar Manifest, as it rebuilds the jar everytime.
  • Loading branch information
shartte authored Oct 9, 2022
1 parent a0b265b commit 341bf57
Show file tree
Hide file tree
Showing 6 changed files with 130 additions and 63 deletions.
18 changes: 18 additions & 0 deletions .github/actions/gradle-setup/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: 'Gradle Setup'
description: 'Set up the basics to run gradle'
runs:
using: "composite"
steps:
- name: Export release tag as environment variable
shell: bash
env:
TAG: ${{ github.event.release.tag_name }}
run: |
echo "TAG=${TAG}" >> $GITHUB_ENV
- name: Set up JDK 17
uses: actions/setup-java@v2
with:
distribution: 'microsoft'
java-version: '17'
cache: 'gradle'
21 changes: 2 additions & 19 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,26 +12,9 @@ jobs:
- name: Set up JDK 17
uses: actions/setup-java@v2
with:
distribution: 'temurin'
distribution: 'microsoft'
java-version: '17'
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Use gradle cache for faster builds
uses: actions/cache@v1
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
- name: Cleanup Gradle Cache
# Remove some files from the Gradle cache, so they aren't cached by GitHub Actions.
# Restoring these files from a GitHub Actions cache might cause problems for future builds.
run: |
rm -f ~/.gradle/caches/modules-2/modules-2.lock
rm -f ~/.gradle/caches/modules-2/gc.properties
- name: Setup Gradle Wrapper Cache
uses: actions/cache@v2
with:
path: ~/.gradle/wrapper
key: ${{ runner.os }}-gradle-wrapper-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }}
cache: 'gradle'
- name: Validate no assets
run: test ! -d ./src/generated
- name: Generate assets
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/localization.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ jobs:
- name: Set up JDK 17
uses: actions/setup-java@v2
with:
distribution: 'temurin'
distribution: 'microsoft'
java-version: '17'
cache: 'gradle'
- uses: actions/setup-node@v2
with:
node-version: "16"
Expand Down
21 changes: 2 additions & 19 deletions .github/workflows/pull_requests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,26 +14,9 @@ jobs:
- name: Set up JDK 17
uses: actions/setup-java@v2
with:
distribution: 'temurin'
distribution: 'microsoft'
java-version: '17'
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Use gradle cache for faster builds
uses: actions/cache@v1
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
- name: Cleanup Gradle Cache
# Remove some files from the Gradle cache, so they aren't cached by GitHub Actions.
# Restoring these files from a GitHub Actions cache might cause problems for future builds.
run: |
rm -f ~/.gradle/caches/modules-2/modules-2.lock
rm -f ~/.gradle/caches/modules-2/gc.properties
- name: Setup Gradle Wrapper Cache
uses: actions/cache@v2
with:
path: ~/.gradle/wrapper
key: ${{ runner.os }}-gradle-wrapper-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }}
cache: 'gradle'
- name: Validate no assets
run: test ! -d ./src/generated
- name: Generate assets
Expand Down
129 changes: 106 additions & 23 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,23 @@ name: 'Release'

on:
release:
types: [published]
types: [ published ]

jobs:
build:
name: Build
runs-on: ubuntu-latest
outputs:
ARTIFACT_PATH: ${{ steps.prepare_artifact_metadata.outputs.ARTIFACT_PATH }}
ARTIFACT_NAME: ${{ steps.prepare_artifact_metadata.outputs.ARTIFACT_NAME }}
JAVADOC_PATH: ${{ steps.prepare_artifact_metadata.outputs.JAVADOC_PATH }}
JAVADOC_NAME: ${{ steps.prepare_artifact_metadata.outputs.JAVADOC_NAME }}
API_PATH: ${{ steps.prepare_artifact_metadata.outputs.API_PATH }}
API_NAME: ${{ steps.prepare_artifact_metadata.outputs.API_NAME }}

steps:
- name: Export release tag as environment variable
env:
TAG: ${{ github.event.release.tag_name }}
run: |
echo "TAG=${TAG}" >> $GITHUB_ENV
- uses: actions/checkout@v2
- name: Set up JDK 17
uses: actions/setup-java@v2
with:
distribution: 'temurin'
java-version: '17'
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- uses: ./.github/actions/gradle-setup
- name: Validate no assets
run: test ! -d ./src/generated
- name: Generate assets
Expand All @@ -41,47 +38,133 @@ jobs:
echo ::set-output name=JAVADOC_NAME::appliedenergistics2-fabric-${VERSION}-javadoc.jar
echo ::set-output name=API_PATH::./build/libs/appliedenergistics2-fabric-${VERSION}-api.jar
echo ::set-output name=API_NAME::appliedenergistics2-fabric-${VERSION}-api.jar
- name: Archive build results
# It is important to archive .gradle as well since gradle stores the incremental build state there
run: tar -I zstd -cf build.tar.zst .gradle build src/generated
- name: Upload build and gradle folders
uses: actions/upload-artifact@v3
with:
name: build-artifacts
path: build.tar.zst
if-no-files-found: error
retention-days: 3

upload-release-artifacts:
name: Upload Release Artifacts
needs: build
runs-on: ubuntu-latest
steps:
- name: Download build artifact
uses: actions/download-artifact@v3
with:
name: build-artifacts
- name: Unpack build artifact
run: tar axf build.tar.zst
- name: Upload Release Artifact
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: ${{ steps.prepare_artifact_metadata.outputs.ARTIFACT_PATH }}
asset_name: ${{ steps.prepare_artifact_metadata.outputs.ARTIFACT_NAME }}
asset_path: ${{ needs.build.outputs.ARTIFACT_PATH }}
asset_name: ${{ needs.build.outputs.ARTIFACT_NAME }}
asset_content_type: application/zip
- name: Upload Javadocs Artifact
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: ${{ steps.prepare_artifact_metadata.outputs.JAVADOC_PATH }}
asset_name: ${{ steps.prepare_artifact_metadata.outputs.JAVADOC_NAME }}
asset_path: ${{ needs.build.outputs.JAVADOC_PATH }}
asset_name: ${{ needs.build.outputs.JAVADOC_NAME }}
asset_content_type: application/zip
- name: Upload API
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: ${{ steps.prepare_artifact_metadata.outputs.API_PATH }}
asset_name: ${{ steps.prepare_artifact_metadata.outputs.API_NAME }}
asset_path: ${{ needs.build.outputs.API_PATH }}
asset_name: ${{ needs.build.outputs.API_NAME }}
asset_content_type: application/zip

deploy-github-packages:
name: Deploy to Github Packages
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: ./.github/actions/gradle-setup
- name: Download build artifact
uses: actions/download-artifact@v3
with:
name: build-artifacts
- name: Unpack build artifact
run: tar axf build.tar.zst
- name: Validate artifacts exist
run: test -d ./build && test -d ./.gradle
- name: Publish to Github Packages
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: ./gradlew publishMavenPublicationToGitHubPackagesRepository --no-daemon --max-workers 1

deploy-curseforge:
name: Deploy to Curseforge
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: ./.github/actions/gradle-setup
- name: Download build artifact
uses: actions/download-artifact@v3
with:
name: build-artifacts
- name: Unpack build artifact
run: tar axf build.tar.zst
- name: Validate artifacts exist
run: test -d ./build && test -d ./.gradle
- name: Upload to Curseforge
env:
CHANGELOG: ${{ github.event.release.body }}
CURSEFORGE: ${{ secrets.CURSEFORGE }}
run: ./gradlew curseforge --no-daemon --max-workers 1
- name: Publish to Github Packages
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: ./gradlew publishMavenPublicationToGitHubPackagesRepository --no-daemon --max-workers 1

deploy-modmaven:
name: Deploy to Modmaven
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: ./.github/actions/gradle-setup
- name: Download build artifact
uses: actions/download-artifact@v3
with:
name: build-artifacts
- name: Unpack build artifact
run: tar axf build.tar.zst
- name: Validate artifacts exist
run: test -d ./build && test -d ./.gradle
- name: Publish to Modmaven
env:
MODMAVEN_USER: ${{ secrets.MODMAVEN_USER }}
MODMAVEN_PASSWORD: ${{ secrets.MODMAVEN_PASSWORD }}
run: ./gradlew publishMavenPublicationToModmavenRepository --no-daemon --max-workers 1

deploy-modrinth:
name: Deploy to Modrinth
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: ./.github/actions/gradle-setup
- name: Download build artifact
uses: actions/download-artifact@v3
with:
name: build-artifacts
- name: Unpack build artifact
run: tar axf build.tar.zst
- name: Validate artifacts exist
run: test -d ./build && test -d ./.gradle
- name: Upload to Modrinth
env:
CHANGELOG: ${{ github.event.release.body }}
Expand Down
1 change: 0 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,6 @@ jar {
"Implementation-Title" : "${project.name}",
"Implementation-Version" : "${project.version}",
"Implementation-Vendor" : "TeamAppliedEnergistics",
"Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ"),
"MixinConfigs" : "ae2.mixins.json"
])
}
Expand Down

0 comments on commit 341bf57

Please sign in to comment.