Skip to content

ci(release): update tag. #2

ci(release): update tag.

ci(release): update tag. #2

name: Manually Release Workflow
on:
workflow_dispatch:
inputs:
prerelease:
description: 'Is this a pre-release?'
required: true
default: false
type: boolean
useRetrievedVersion:
description: 'Use the version retrieved from the project?'
required: true
default: true
type: boolean
alternativeVersion:
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:
runs-on:
ubuntu-latest
timeout-minutes: 360 # 6 hours
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: 17
distribution: 'zulu'
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v3
with:
build-scan-publish: false
- name: Retrieve Version
run: |
chmod +x gradlew
VERSION_NAME=$(./gradlew -q :version)
echo "VERSION_NAME=$VERSION_NAME" >> "$GITHUB_OUTPUT"
id: project_version
- name: Get version
run: |
echo "raw_version_name=${{ steps.project_version.outputs.VERSION_NAME }}" >> $GITHUB_ENV
if ${{ github.event.inputs.useRetrievedVersion }}; then
echo "version_name=v${{ steps.project_version.outputs.VERSION_NAME }}" >> $GITHUB_ENV
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

Check failure on line 61 in .github/workflows/manually_release.yaml

View workflow run for this annotation

GitHub Actions / .github/workflows/manually_release.yaml

Invalid workflow file

You have an error in your yaml syntax on line 61
- 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
uses: actions/github-script@v7.0.1
id: create_tag
with:
script: |
github.rest.git.createRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: 'refs/tags/${{ env.version_name }}',
sha: context.sha
})
- name: Checkout Tag
uses: actions/checkout@v4
with:
ref:
${{ env.version_name }}
- 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: |
# ${{ 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 }}
files: |
build/dist/lamp-blog-${{ env.raw_version_name }}-dist.tar.gz
build/dist/lamp-blog-${{ env.raw_version_name }}-image.tar.gz
- name: Remove Tag
uses: actions/github-script@v7.0.1
if: failure() && steps.build.outcome == 'failure'
with:
script: |
github.rest.git.deleteRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: 'refs/tags/${{ env.version_name }}'
})