Skip to content

Publish Release

Publish Release #27

name: Publish Release
on:
workflow_dispatch:
jobs:
Ubuntu:
runs-on: ubuntu-latest
steps:
- name: Checkout
id: checkout
uses: actions/[email protected]
with:
token: ${{ secrets.WSO2_INTEGRATION_BOT_TOKEN }}
fetch-depth: 0
- name: Set up JDK 11
uses: joschi/setup-jdk@v2
with:
distribution: 'adopt'
java-version: 11
- name: Extract version from pom.xml
id: extract_version
run: |
# Extract version from pom.xml using xmlstarlet
VERSION=$(xmlstarlet sel -t -m "/project/version" -v . pom.xml)
#echo "VERSION=$VERSION" >> $GITHUB_ENV # Set version in environment variable
VERSION_TAG="v$VERSION"
echo "VERSION_TAG=$VERSION_TAG" >> $GITHUB_ENV
- name: Configure Maven settings file
run: |
mkdir -p ~/.m2
echo "<settings>
<servers>
<server>
<id>nexus-releases</id>
<username>${{ secrets.NEXUS_USERNAME }}</username>
<password>${{ secrets.NEXUS_PASSWORD }}</password>
</server>
</servers>
</settings>" > ~/.m2/settings.xml
- name: Configure git credentials
run: |
git config --global user.name ${{ secrets.WSO2_INTEGRATION_BOT_USERNAME }}
git config --global user.email ${{ secrets.WSO2_INTEGRATION_BOT_EMAIL }}
- name: Build artifacts
run: |
mvn clean install
# - name: Backup target directory
# run: |
# if [ -d "target" ]; then
# tar -czf target-backup.tar.gz target/
# fi
- name: Deploy artifacts with Maven
env:
GITHUB_TOKEN: ${{ secrets.WSO2_INTEGRATION_BOT_TOKEN }}
run: |
mvn --batch-mode release:prepare release:perform -Dtag=${{ env.VERSION_TAG }}
# TAG_NAME=$(git describe --tags --abbrev=0)
# echo "TAG_NAME=$TAG_NAME" >> $GITHUB_ENV
# - name: Restore target directory
# run: |
# if [ -f "target-backup.tar.gz" ]; then
# tar -xzf target-backup.tar.gz
# fi
- name: Create Release with Assets
env:
GITHUB_TOKEN: ${{ secrets.WSO2_INTEGRATION_BOT_TOKEN }}
# tag: ${{ github.ref_name }}
run: |
# echo $tag
find target/ -type f -name '*-SNAPSHOT.zip' -exec rm -f {} \;
gh release create "${{ env.VERSION_TAG }}" \
--repo="$GITHUB_REPOSITORY" \
--title="${{ env.VERSION_TAG }}" \
--generate-notes \
target/*.zip