diff --git a/.forgejo/workflows/build.yml b/.forgejo/workflows/build.yml index 1172c99..fa3751d 100644 --- a/.forgejo/workflows/build.yml +++ b/.forgejo/workflows/build.yml @@ -29,17 +29,40 @@ jobs: - name: Get tags from GitLab repository id: get_tags run: | - TAGS=$(curl --header "PRIVATE-TOKEN: ${{ secrets.GITLAB_ACCESS_TOKEN }}" "https://gitlab.com/api/v4/projects/liberaforms%2Fliberaforms/repository/tags" | jq -r '.[].name') - echo "tags=$TAGS" >> $GITHUB_OUTPUT + TAGS=$(curl "https://gitlab.com/api/v4/projects/liberaforms%2Fliberaforms/repository/tags" | jq -r '.[].name') + echo "All available tags:" + echo "$TAGS" + echo "$TAGS" > /tmp/all_tags.txt - name: Filter out RC and dev tags and get the latest version id: filter_tags run: | - TAGS="${{ steps.get_tags.outputs.tags }}" - FILTERED_TAGS=$(echo "$TAGS" | grep -Ev 'RC[0-9]$|dev' | sort -V | tail -n 1) - echo "Latest tag excluding RC and dev: $FILTERED_TAGS" - echo "latest_tag=$FILTERED_TAGS" >> $GITHUB_OUTPUT - + if [ -f "/tmp/all_tags.txt" ]; then + TAGS=$(cat /tmp/all_tags.txt) + echo "All tags before filtering:" + echo "$TAGS" + + # Use simple grep commands separately to ensure proper filtering + # Retain only tags that don't contain "-dev" and don't contain "-RC" + FILTERED_TAGS=$(echo "$TAGS" | grep -v "\-dev" | grep -v "\-RC") + + echo "Tags after filtering:" + echo "$FILTERED_TAGS" + + if [ -z "$FILTERED_TAGS" ]; then + echo "No tags matched the filter criteria" + echo "latest_tag=" >> $GITHUB_OUTPUT + else + # Sort versions and get the latest + LATEST_TAG=$(echo "$FILTERED_TAGS" | sort -V | tail -n 1) + echo "Latest tag excluding RC and dev: $LATEST_TAG" + echo "latest_tag=$LATEST_TAG" >> $GITHUB_OUTPUT + fi + else + echo "Error: Tag file not found" + echo "latest_tag=" >> $GITHUB_OUTPUT + fi + - name: Build and Push with Latest Tag uses: docker/build-push-action@v4 with: