version-input-test #2
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: version-input-test | |
on: | |
workflow_dispatch: | |
inputs: | |
version: | |
description: 'enter version(x.y.z)' | |
required: true | |
default: '1.0.0' | |
container_arch: | |
type: choice | |
description: 'choose container architecture' | |
default: linux/amd64 | |
options: | |
- "linux/amd64" | |
- "linux/amd64,linux/arm64" | |
env: | |
ARCH: ${{ github.event.inputs.container_arch }} | |
VERSION: ${{ github.event.inputs.version }} | |
jobs: | |
check-version: | |
runs-on: ubuntu-latest | |
outputs: | |
new_commit_sha: ${{ steps.get_sha.outputs.NEW_COMMIT_SHA }} | |
steps: | |
- name: check version format | |
run: | | |
if [[ !(${{ env.VERSION }} =~ ^[0-9]\.[0-9]?[0-9]\.[0-9]?[0-9]$) ]]; | |
then | |
echo "포멧 틀렸다 수정해라" | |
exit 1 | |
fi | |
- name: debugging | |
run: | | |
echo "major=$(echo ${{env.VERSION}} | cut -c 2- | cut -d'.' -f1)" | |
echo "minor=$(echo ${{env.VERSION}} | cut -c 2- | cut -d'.' -f2)" | |
echo "patch=$(echo ${{env.VERSION}} | cut -c 2- | cut -d'.' -f3)" | |
- name: Change version | |
run: | | |
converted_version=$(echo ${{ env.VERSION }} | sed -E 's/^([0-9]+\.[0-9]+)\.([a-zA-Z]+)/\1.0-\2/') | |
echo "converted_version=$converted_version" >> "$GITHUB_OUTPUT" | |
- name: Check if there are any changes | |
id: check_changes | |
run: | | |
git diff --exit-code --quiet || echo "::set-output name=changed::true" | |
continue-on-error: true | |
- name: Log File Contents 2 | |
run: | | |
file_path="./package.json" | |
cat "$file_path" |