Skip to content

removed SubredditPostSupplier.java #50

removed SubredditPostSupplier.java

removed SubredditPostSupplier.java #50

Workflow file for this run

name: Release
on:
workflow_dispatch:
inputs:
release_type:
description: "Release type"
type: choice
options:
- patch
- minor
- major
- provided
env:
JAR_NAME_TEMPLATE: reddit-telegram-repeater-*-shaded.jar
TAG: v${{ github.event.inputs.version }}
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'corretto'
cache: maven
- name: Run test
run: mvn test
env:
spring.jpa.hibernate.ddl-auto: create-drop
telegram.admin.id: ${{ secrets.telegram.admin.id }}
telegram.bot.token: ${{ secrets.test.telegram.bot.token }}
telegram.channel.id: ${{ secrets.test.telegram.channel.id }}
telegram.chat.id: ${{ secrets.test.telegram.chat.id }}
telegram.schedule.posting.enabled: false
release:
runs-on: ubuntu-latest
needs: test
steps:
- name: Install XMLStarlet
run: sudo apt-get install xmlstarlet
- name: Checkout
uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'corretto'
cache: maven
- name: Get current version
id: get_current_version
run: |
current_version=$(xmlstarlet sel -N pom=http://maven.apache.org/POM/4.0.0 -t -v "/pom:project/pom:version" pom.xml)
echo "current_version=$current_version"
echo "VERSION=$current_version" >> $GITHUB_ENV
- name: Validate current version
if: github.event.inputs.release_type != 'provided'
run: |
echo ${{ env.VERSION }} | grep -qoP "^\d+\.\d+\.\d+((\.|-).+)?$" || (echo "::error::Unexpected artifact version found in pom.xml: ${{ env.VERSION }}. Expected format: x.y.z*" && exit 1)
- name: Increment patch version
if: github.event.inputs.release_type == 'patch'
run: |
patch_version=$(echo ${{ env.VERSION }} | grep -oP "^\d+\.\d+\.\K\d+")
echo "patch_version=$patch_version"
incremented_patch_version=$((patch_version + 1))
echo "incremented_patch_version=$incremented_patch_version"
echo "VERSION=$(echo ${{ env.VERSION }} | grep -oP '^\d+\.\d+\.')$incremented_patch_version" >> $GITHUB_ENV
- name: Increment minor version
if: github.event.inputs.release_type == 'minor'
run: |
minor_version=$(echo ${{ env.VERSION }} | grep -oP "^\d+\.\K\d+")
echo "minor_version=$minor_version"
incremented_minor_version=$((minor_version + 1))
echo "incremented_minor_version=$incremented_minor_version"
echo "VERSION=$(echo ${{ env.VERSION }} | grep -oP '^\d+\.')$incremented_minor_version.0" >> $GITHUB_ENV
- name: Increment major version
if: github.event.inputs.release_type == 'major'
run: |
major_version=$(echo ${{ env.VERSION }} | grep -oP "^\d+")
echo "major_version=$major_version"
incremented_major_version=$((major_version + 1))
echo "incremented_major_version=$incremented_major_version"
echo "VERSION=$incremented_major_version.0.0" >> $GITHUB_ENV
- name: Print new version
run: echo "new_version=${{ env.VERSION }}"
- name: Update pom.xml version
run: xmlstarlet ed -P -L -N pom=http://maven.apache.org/POM/4.0.0 -u "/pom:project/pom:version" -v ${{ env.VERSION }} pom.xml
- name: Set Tag name
run: echo "TAG=v${{ env.VERSION }}" >> $GITHUB_ENV
- name: Commit & Push changes
run: |
git config user.email "github-actions@github.com"
git config user.name "github-actions"
git add pom.xml
git commit -m "${{ env.TAG }}"
git push
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ env.TAG }}
release_name: ${{ env.TAG }}
draft: true
check_input:
runs-on: ubuntu-latest
steps:
- name: Check input
id: check_input
run: |
[[ ${{ github.event.inputs.version }} =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]] && echo "match=true" >> $GITHUB_OUTPUT || echo "match=false" >> $GITHUB_OUTPUT
- name: Validate input
if: steps.check_input.outputs.match != 'true'
run: |
echo "::error::Incorrect release version format: ${{ github.event.inputs.version }}. Expected format: x.y.z."
exit 1
release:

Check failure on line 125 in .github/workflows/release.yml

View workflow run for this annotation

GitHub Actions / .github/workflows/release.yml

Invalid workflow file

You have an error in your yaml syntax on line 125
runs-on: ubuntu-latest
needs: [ check_input ]
steps:
- name: Set JAR_NAME
run: |
echo "JAR_NAME=${{ env.JAR_NAME_TEMPLATE }}" | sed "s/*/${{ github.event.inputs.version }}/g" >> $GITHUB_ENV
- name: Set JAR_PATH
run: |
echo "JAR_PATH=target/${{ env.JAR_NAME }}" >> $GITHUB_ENV
- name: Set RUN_CMD
run: |
echo "RUN_CMD=${{ secrets.REMOTE_DIR }}"
- name: Checkout
uses: actions/checkout@v3
- name: Create Tag
uses: rickstaa/action-create-tag@v1
with:
tag: ${{ env.TAG }}
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'corretto'
cache: maven
- name: Build with Maven
run: mvn package
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ env.TAG }}
release_name: ${{ env.TAG }}
draft: true
- name: Upload Release Asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ${{ env.JAR_PATH }}
asset_name: ${{ env.JAR_NAME }}
asset_content_type: application/java-archive
- name: Upload artifact to remote
uses: cross-the-world/ssh-scp-ssh-pipelines@latest
with:
host: ${{ secrets.REMOTE_HOST }}
user: ${{ secrets.REMOTE_USER }}
pass: ${{ secrets.REMOTE_PASS }}
port: ${{ secrets.REMOTE_PORT }}
first_ssh: |
cd ${{ secrets.REMOTE_DIR }}
rm -rf ${{ env.JAR_NAME_TEMPLATE }}
scp: |
${{ env.JAR_PATH }} => ${{ secrets.REMOTE_DIR }}
last_ssh: |
cd ${{ secrets.REMOTE_DIR }}
echo ${{ secrets.RUN_CMD }} | sed "s/{version}/${{ github.event.inputs.version }}/g" > ${{ secrets.RUN_FILE }}