Skip to content

Commit

Permalink
ci: Merge github and npm releases. (#26)
Browse files Browse the repository at this point in the history
  • Loading branch information
Zurcusa authored Sep 24, 2024
1 parent 40cc9d2 commit 79262ae
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 34 deletions.
89 changes: 56 additions & 33 deletions .github/workflows/tag-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,6 @@ jobs:
with:
ref: dev

- name: Write release version
run: |
VERSION=${{ github.event.inputs.tag_name }}
echo "Releasing version: $VERSION"
sed -i -e 's@version = .\d*.\d*.\d*.*@version = "'"$VERSION"'"@g' build.gradle.kts
- name: Create or use provided tag
run: |
# Use provided tag from the input
Expand All @@ -54,23 +48,6 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Set up cache for Gradle
uses: actions/cache@v4
with:
path: ~/.gradle/caches
key: gradle-${{ runner.os }}-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
gradle-${{ runner.os }}
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'corretto'

- name: Build Gradle Project
run: ./gradlew build

github-release:
name: Create GitHub Release
runs-on: ubuntu-latest
Expand All @@ -84,13 +61,37 @@ jobs:

- name: Build Changelog
id: changelog
uses: requarks/changelog-action@v11
continue-on-error: true
uses: requarks/changelog-action@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
token: ${{ github.token }}
tag: ${{ github.event.inputs.tag_name }}

- name: Write release version
run: |
VERSION=${{ github.event.inputs.tag_name }}
echo "Releasing version: $VERSION"
sed -i -e 's@version = .\d*.\d*.\d*.*@version = "'"$VERSION"'"@g' build.gradle.kts
- name: Set up cache for Gradle
uses: actions/cache@v4
with:
path: ~/.gradle/caches
key: gradle-${{ runner.os }}-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
gradle-${{ runner.os }}
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'corretto'

- name: Build Gradle Project
run: ./gradlew build

- name: Create release
id: create_release
uses: actions/create-release@v1
Expand All @@ -99,7 +100,7 @@ jobs:
with:
tag_name: ${{ github.event.inputs.tag_name }}
release_name: Release ${{ github.event.inputs.tag_name }}
body: ${{ steps.changelog.outputs.changes }}
body: ${{ steps.changelog.outputs.changes || 'No changelog available' }}
draft: false
prerelease: false

Expand All @@ -110,9 +111,9 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./build/libs/Fruzhin-${{ github.event.inputs.tag_name }}.jar
asset_name: Fruzhin-${{ github.event.inputs.tag_name }}.jar
asset_content_type: application/java-archive
asset_path: ./build/libs/Fruzhin-${{ github.event.inputs.tag_name }}.war
asset_name: Fruzhin-${{ github.event.inputs.tag_name }}.war
asset_content_type: application/x-zip

npm-release:
name: Publish to NPM
Expand All @@ -125,18 +126,40 @@ jobs:
with:
ref: ${{ github.event.inputs.tag_name }}

- name: Set up cache for Gradle
uses: actions/cache@v4
with:
path: ~/.gradle/caches
key: gradle-${{ runner.os }}-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
gradle-${{ runner.os }}
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'corretto'

- name: Build Gradle Project
run: ./gradlew build

- name: Unzip WAR file
run: |
unzip build/libs/*.war -d dist
rm -rf dist/META-INF dist/WEB-INF dist/index.html
ls -l
unzip ./build/libs/*.war -d dist
rm -rf ./dist/META-INF ./dist/WEB-INF ./dist/index.html
- name: Update package.json version
run: |
VERSION=${{ github.event.inputs.tag_name }}
echo "Updating package.json with version: $VERSION"
sed -i -e 's/"version": ".*"/"version": "'"$VERSION"'"/' package.json
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '20'

- name: Install NPM dependencies
run: npm install
registry-url: "https://registry.npmjs.org"

- name: Publish to NPM
env:
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "fruzhin-web",
"name": "fruzhin",
"version": "1.0.0",
"description": "An implementation of Fruzhin's light client usable in the web.",
"main": "./dist/js/fruzhin-lib.js",
Expand Down

0 comments on commit 79262ae

Please sign in to comment.