Skip to content

adds workflows

adds workflows #1

Workflow file for this run

# This is a basic workflow to help you get started with Actions
name: CI
# Controls when the action will run. Triggers the workflow on push or pull request
# events but only for the master branch
on:
push:
branches: [ main ]
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
runs-on: ubuntu-latest
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2
with:
path: './crucible'
- id: crucible
uses: pozetroninc/[email protected]
with:
owner: cmu-sei
repo: moodle-block_crucible
excludes: prerelease, draft
- name: package
run: |
OLDRELEASE=${{ steps.crucible.outputs.release }}
PREVIOUSVERSION=$(grep "plugin->version" crucible/version.php | sed -e "s/.*= \(.*\);.*/\1/")
if [ $OLDRELEASE -ne $PREVIOUSVERSION ]; then
NEWVERSION=$PREVIOUSVERSION
else
OLDDATE=`echo $PREVIOUSVERSION | cut -b 1-8`
NEWDATE=`date +%Y%m%d`
if [ $OLDDATE -ne $NEWDATE ]; then
NEWVERSION=$NEWDATE\00
else
OLDVERS=`echo $PREVIOUSVERSION | cut -b 9-10`
OLDVERS=${OLDVERS#0}
let NEWVERS=(OLDVERS + 1)
NEWVERSION=$OLDDATE`printf %02d $NEWVERS`
fi
sed -i "s#$PREVIOUSVERSION#$NEWVERSION#" crucible/version.php
cd ./crucible
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add version.php
git commit -m "Updating version to $NEWVERSION"
git push
cd ..
fi
zip -r block_crucible_$NEWVERSION.zip crucible/ -x "crucible/*.git*"
echo "artifact_version=$NEWVERSION" >> $GITHUB_ENV
echo "artifact_name=block_crucible_$NEWVERSION" >> $GITHUB_ENV
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
with:
tag_name: ${{ env.artifact_version }}
release_name: ${{ env.artifact_name }}
draft: false
prerelease: false
- name: Upload Release Asset
id: 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.artifact_name}}.zip
asset_name: ${{env.artifact_name}}.zip
asset_content_type: application/zip