File Integrity Scanner Plugin For OJS 3.3.x #7
Workflow file for this run
This file contains hidden or 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
| # .github/workflows/BuildAndRelease.yml.yml | |
| name: Build and Upload Release Package | |
| # Trigger: This workflow ONLY runs when a new release is created in GitHub | |
| on: | |
| release: | |
| types: [created] | |
| jobs: | |
| build-release-package: | |
| runs-on: ubuntu-latest | |
| # Permissions are required for the workflow to upload assets to the release | |
| permissions: | |
| contents: write | |
| steps: | |
| # 1. Checkout the code from the tag that triggered this release | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: ${{ github.event.release.tag_name }} | |
| # 2. Get the tag name to use in the filename | |
| - name: Get tag name | |
| run: | | |
| echo "TAG_NAME=${{ github.event.release.tag_name }}" >> $GITHUB_ENV | |
| # 3. Create the .tar.gz release package | |
| - name: Create release package | |
| run: | | |
| # The root directory name inside the tarball, as per OJS standards | |
| PLUGIN_DIR_NAME="ashFileIntegrity" | |
| # Define the tarball filename | |
| TARBALL="${PLUGIN_DIR_NAME}-${TAG_NAME}.tar.gz" | |
| TARBALL_PATH="$RUNNER_TEMP/${TARBALL}" | |
| # Create the .tar.gz archive | |
| # --transform will place all files into the PLUGIN_DIR_NAME directory | |
| tar -czf "${TARBALL_PATH}" \ | |
| --exclude='.git' \ | |
| --exclude='.github' \ | |
| --exclude='cypress' \ | |
| --exclude='tests' \ | |
| --exclude='.gitignore' \ | |
| --transform "s|^\.|${PLUGIN_DIR_NAME}|" \ | |
| . | |
| # Save the tarball name and path for subsequent steps | |
| echo "TARBALL=${TARBALL}" >> $GITHUB_ENV | |
| echo "TARBALL_PATH=${TARBALL_PATH}" >> $GITHUB_ENV | |
| # 4. Calculate the MD5 hash of the release package | |
| - name: Calculate MD5 hash | |
| run: | | |
| MD5=$(md5sum $TARBALL_PATH | awk '{print $1}') | |
| echo "MD5 Hash: ${MD5}" | |
| echo "MD5=${MD5}" >> $GITHUB_ENV | |
| # 5. Upload the .tar.gz package as an asset to the release page | |
| - name: Upload package to release | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| gh release upload $TAG_NAME $TARBALL_PATH --clobber | |
| # 6. Update the release notes with the MD5 hash | |
| - name: Update release notes with MD5 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| CURRENT_BODY="$(gh release view "$TAG_NAME" --json body --jq .body)" | |
| gh release edit $TAG_NAME --notes "$( | |
| printf '%s\n\n%s\n\n%s\n' \ | |
| "${CURRENT_BODY}" \ | |
| "## Download Verification" \ | |
| "MD5 Hash for \`$TARBALL\`: \`$MD5\`" | |
| )" |