Skip to content

Build and release

Build and release #70

Workflow file for this run

permissions:
contents: write
deployments: write
name: Build and release
on:
push:
tags:
- "v*"
workflow_dispatch:
jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Get the latest tag and date
id: version_info
run: |
echo "tag=$(echo $GITHUB_REF | sed 's/refs\/tags\///')" >> $GITHUB_ENV
echo "date=$(date +"(%m-%d-%Y)")" >> $GITHUB_ENV
WallGoMatrixVersion=$(grep -oP 'WallGoMatrix`\$WallGoMatrixVersion = "\K[^"]+' WallGoMatrix.m)
WallGoMatrixVersionDate=$(grep -oP 'WallGoMatrix`\$WallGoMatrixVersionDate = "\K[^"]+' WallGoMatrix.m)
- name : Debugging
run: |
echo "WallGoMatrixVersion: $WallGoMatrixVersion"
echo "WallGoMatrixVersionDate: $WallGoMatrixVersionDate"
# - name: Check if WallGoMatrixVersion matches GitHub tag
# run: |
# if [ "$WallGoMatrixVersion" == "${{ env.tag }}" ]; then
# echo "Error: WallGoMatrixVersion ($WallGoMatrixVersion) does not match tag (${{ env.tag }})" 1>&2
# exit 64
# else
# echo "WallGoMatrixVersion matches the tag"
# fi
- name: Update version and date in WallGoMatrix.m
run: |
sed -i.bak \
-e "s/WallGoMatrix\`\$WallGoMatrixVersion = \".*\";/WallGoMatrix\`\$WallGoMatrixVersion = \"${{ env.tag }}\"\;/" \
-e "s/WallGoMatrix\`\$WallGoMatrixVersionDate = \".*\"\;/WallGoMatrix\`\$WallGoMatrixVersionDate = \"${{ env.date }}\"\;/" \
WallGoMatrix.m
# - name: Commit and push version update
# run: |
# git config --global user.name 'github-actions'
# git config --global user.email 'github-actions@github.com'
# rm WallGoMatrix.m.bak
# git add WallGoMatrix.m
# git commit -m "Update WallGoMatrix version to ${{ env.tag }} and date to ${{ env.date }}"
# git push origin HEAD
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
draft: false
prerelease: false
- name: Build Release Asset
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
mkdir -p WallGoMatrix
cp -r src WallGoMatrix/
cp WallGoMatrix.m WallGoMatrix/
zip -r WallGoMatrix_${{ github.ref_name }}.zip WallGoMatrix/*
rm -r WallGoMatrix
ls -a
- name: 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: ./WallGoMatrix_${{ github.ref_name }}.zip
asset_name: WallGoMatrix_${{ github.ref_name }}.zip
asset_content_type: application/zip