update version #33
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: Build Plugin and Create Release | |
on: | |
push: | |
branches: | |
- master | |
env: | |
JAVA_HOME: /usr/lib/jvm/java-11-openjdk-amd64 | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Set up Java | |
uses: actions/setup-java@v2 | |
with: | |
java-version: '11' | |
distribution: 'adopt' | |
- name: Grant execute permission to gradlew | |
run: chmod +x gradlew | |
- name: Build plugin | |
run: $GITHUB_WORKSPACE/gradlew buildPlugin | |
- name: Get plugin file path | |
id: get_plugin_file | |
run: echo "::set-output name=plugin_file::$(find ${{ github.workspace }}/build/distributions -name '*.zip' -type f)" | |
- name: Archive plugin | |
run: mv ${{ steps.get_plugin_file.outputs.plugin_file }} ${{ github.workspace }}/plugin.zip | |
- name: Generate version number | |
id: version | |
run: | | |
DATE=$(date +'%Y%m%d') | |
RELEASES=$(curl -s -H "Authorization: Bearer ${{ secrets.MY_TOKEN }}" \ | |
"https://api.github.com/repos/${{ github.repository }}/releases") | |
VERSION="v${DATE}.1" | |
if [[ $RELEASES == *"$VERSION"* ]]; then | |
COUNT=2 | |
while [[ $RELEASES == *"${VERSION%.*}.${COUNT}"* ]]; do | |
COUNT=$((COUNT + 1)) | |
done | |
VERSION="${VERSION%.*}.${COUNT}" | |
fi | |
echo "VERSION=$VERSION" >> $GITHUB_ENV | |
- name: Create Release | |
id: create_release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.MY_TOKEN }} | |
with: | |
tag_name: ${{ env.VERSION }} | |
release_name: Release ${{ env.VERSION }} | |
body: | | |
Release ${{ env.VERSION }} | |
draft: false | |
prerelease: false | |
- name: Upload plugin artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: plugin | |
path: plugin.zip | |
- name: Attach plugin artifact to Release | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.MY_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: ${{ github.workspace }}/plugin.zip | |
asset_name: plugin.zip | |
asset_content_type: application/zip |