Skip to content

Bump version to v5.8.2 (#73) #4

Bump version to v5.8.2 (#73)

Bump version to v5.8.2 (#73) #4

Workflow file for this run

name: Create Github release
on:
workflow_dispatch:
push:
branches:
- master
paths:
- 'VERSION'
permissions:
contents: write
jobs:
variables:
name: Read VERSION and changelog
# if: github.repository == 'adjust/web_sdk' - commented temporary, just for testing
runs-on: ubuntu-latest
outputs:
version: ${{ steps.read-file.outputs.version }}
changelog: ${{ steps.prepare-changelog.outputs.changelog }}
steps:
- uses: actions/checkout@v4
- name: Read VERSION file
id: read-file
shell: bash
run: |
# Enable strict bash mode:
# -e - exit immediately if any command fails
# -u - treat unset variables as an error
# -o pipefail - fail the script if any command in a pipeline fails
set -euo pipefail
version="$(tr -d ' \t\r\n' < VERSION)"
echo "version=$version" >> "$GITHUB_OUTPUT"
- name: Prepare changelog
id: prepare-changelog
run: |
set -euo pipefail
read_changelog() {
CHANGELOG_FILE="./CHANGELOG.md"
change_log_found=false
while IFS='' read -r line || [[ -n "$line" ]]; do
# If it is reading change log for the version
if $change_log_found; then
# If it reads end of change log for the version
if [[ "$line" == "---" ]]; then
break
# Append the line
else
echo "$line"
fi
# If it didn't find changelog for the version
else
# If it is the first line of change log for the version
if [[ "$line" =~ "### Version ${{ steps.read-file.outputs.version }}" ]]; then
change_log_found=true
fi
fi
done < $CHANGELOG_FILE
}
changes=$(read_changelog)
echo "changelog<<EOF" >> $GITHUB_OUTPUT
echo "$changes" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
prepare-release:
name: Publish Github release
if: github.repository == 'adjust/web_sdk'
runs-on: ubuntu-latest
needs: [variables]
steps:
- uses: actions/checkout@v4
- name: Push tag
shell: bash
run: |
set -euo pipefail
VERSION="${{ needs.variables.outputs.version }}"
TAG="v$VERSION"
git config --local user.name "github-actions[bot]"
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git tag -a "$TAG" -m "Version $VERSION"
git push origin "$TAG"
- uses: ncipollo/release-action@v1
with:
tag: v${{ needs.variables.outputs.version }}
draft: true
name: Version ${{ needs.variables.outputs.version }}
body: ${{ needs.variables.outputs.changelog }}
artifacts: "dist/*"