Skip to content

Commit

Permalink
ci: update release workflow.
Browse files Browse the repository at this point in the history
  • Loading branch information
roll-w committed Nov 9, 2024
1 parent ea8712a commit e8280d7
Showing 1 changed file with 38 additions and 3 deletions.
41 changes: 38 additions & 3 deletions .github/workflows/manually_release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ on:
description: 'Alternative version to use if not using the retrieved version'
required: false
type: string
namespace:
description: 'Namespace to use for the image, default to the repository owner'
required: false
type: string
permissions: write-all
jobs:
build:
Expand All @@ -31,7 +35,7 @@ jobs:
java-version: 17
distribution: 'zulu'
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v3
uses: gradle/actions/setup-gradle@v4
with:
build-scan-publish: false
- name: Retrieve Version
Expand All @@ -48,10 +52,19 @@ jobs:
else
echo "version_name=${{ github.event.inputs.alternativeVersion }}" >> $GITHUB_ENV
fi
- name: Set Namespace
run: |
if [ -z "${{ github.event.inputs.namespace }}" ]; then
echo "namespace=${{ github.repository_owner }}" >> $GITHUB_ENV
else
echo "namespace=${{ github.event.inputs.namespace }}" >> $GITHUB_ENV
fi
- name: Install Dependencies
run: |
git clone https://github.com/roll-w/web-common-starter
cd web-common-starter
# TODO: retrieve version from gradle task
git checkout v0.2.1
mvn -f web-common-parent/ clean install
cd ..
- name: Create Tag
Expand All @@ -70,17 +83,39 @@ jobs:
with:
ref:
${{ env.version_name }}
- name: Build package and Docker image
- name: Build Package and Docker Image
id: build
continue-on-error: true
run: |
chmod +x gradlew
./gradlew packageImage
- name: Push Image
id: push
run: |
echo ${{ secrets.GITHUB_TOKEN }} | docker login ghcr.io -u ${{ github.actor }} --password-stdin
docker tag lamp-blog:${{ env.raw_version_name }} ghcr.io/${{ env.namespace }}/lamp-blog:${{ env.raw_version_name }}
docker push ghcr.io/${{ env.namespace }}/lamp-blog:${{ env.raw_version_name }}
sha=$(docker inspect ghcr.io/${{ env.namespace }}/lamp-blog:${{ env.raw_version_name }} --format='{{index .RepoDigests 0}}')
echo "digest=$sha" >> $GITHUB_OUTPUT
- name: Release
if: steps.build.outcome == 'success'
uses: softprops/action-gh-release@v2
with:
body: Bump Version
body: |
# ${{ env.version_name }}
Release for version ${{ env.raw_version_name }}
## Changes
## Artifacts
- Image: ghcr.io/${{ env.namespace }}/lamp-blog:${{ env.raw_version_name }}
- sha: `${{ steps.push.outputs.digest }}`
Pull image from `ghcr.io/${{ env.namespace }}/lamp-blog:${{ env.raw_version_name }}`
or download the image package from current release assets.
draft: true
tag_name: ${{ env.version_name }}
prerelease: ${{ github.event.inputs.prerelease }}
Expand Down

0 comments on commit e8280d7

Please sign in to comment.