Build and release #69
Workflow file for this run
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
permissions: | |
contents: write | |
deployments: write | |
name: Build and release | |
on: | |
push: | |
tags: | |
- "v*" | |
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 | |
- 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 branch # Check the current detached state | |
branch_name=$(echo $GITHUB_REF | sed 's/refs\/heads\///') | |
echo "Pushing to branch: $branch_name" | |
git push origin HEAD:$branch_name | |
- 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 |