Merge pull request #50 from danielvijge/feature/wip-202411118 #49
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: Release | |
on: | |
push: | |
branches: | |
- master | |
tags: | |
- '**' | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
with: | |
persist-credentials: false | |
fetch-depth: 0 | |
- name: Set version number (release build) | |
if: contains(github.ref, 'refs/tags/') | |
run: | | |
echo "VERSION=`echo ${GITHUB_REF##*/}`" >> $GITHUB_ENV | |
echo "RELEASE_CHANNEL=release" >> $GITHUB_ENV | |
echo "FOLDER=." >> $GITHUB_ENV | |
- name: Set version number (development build) | |
if: "!contains(github.ref, 'refs/tags/')" | |
run: | | |
echo "VERSION=`git describe --tags --abbrev=0`.`git rev-list $(git describe --tags --abbrev=0)..HEAD --count`-dev" >> $GITHUB_ENV | |
echo "RELEASE_CHANNEL=dev" >> $GITHUB_ENV | |
echo "FOLDER=dev-builds" >> $GITHUB_ENV | |
- name: Test if release number matches x.y | |
if: env.RELEASE_CHANNEL == 'release' | |
run: | | |
! [[ ${{ env.VERSION }} =~ ^[0-9]+.[0-9]+$ ]] && echo "Release tag must be in the form of x.y." && exit 1 || echo "Release tag format is correct" | |
- name: Create install XML file | |
uses: cuchi/jinja2-action@v1.2.0 | |
with: | |
template: install.template.xml | |
output_file: install.xml | |
strict: true | |
- name: Build package | |
run: | | |
zip -r SqueezeCloud-${{ env.VERSION }}.zip . -x \*.zip \*.sh \*.git\* \*README\* \*webauth\* \*.sublime\* \*.DS_Store\* \*.editorconfig \*.template.xml | |
- name: Calculate SHA | |
run: | | |
echo "SHA=$(shasum SqueezeCloud-${{ env.VERSION }}.zip | awk '{print $1;}')" >> $GITHUB_ENV | |
- name: Create dev channel public XML file | |
uses: cuchi/jinja2-action@v1.2.0 | |
with: | |
template: public.template.xml | |
output_file: public-dev.xml | |
strict: true | |
- name: Create release public XML file | |
if: env.RELEASE_CHANNEL == 'release' | |
uses: cuchi/jinja2-action@v1.2.0 | |
with: | |
template: public.template.xml | |
output_file: public.xml | |
strict: true | |
- name: Switch branch, setup git for push | |
run: | | |
mv public*.xml /tmp | |
mv SqueezeCloud-${{ env.VERSION }}.zip /tmp | |
git checkout gh-pages | |
cp /tmp/SqueezeCloud-${{ env.VERSION }}.zip ${{ env.FOLDER }}/ | |
cp /tmp/public*.xml . | |
git config --local user.email "actions@github.com" | |
git config --local user.name "GitHub Actions" | |
git add ${{ env.FOLDER }}/SqueezeCloud-${{ env.VERSION }}.zip | |
git commit -m "Github Actions release ${{ env.VERSION }}" -a | |
- name: Push changes to gh-pages | |
uses: ad-m/github-push-action@master | |
with: | |
branch: gh-pages | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
- name: Create release | |
if: env.RELEASE_CHANNEL == '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: ${{ github.ref }} | |
release_name: Release ${{ env.VERSION }} | |
draft: false | |
prerelease: false | |
- name: Upload Release Asset | |
if: env.RELEASE_CHANNEL == 'release' | |
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 }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps | |
asset_path: SqueezeCloud-${{ env.VERSION }}.zip | |
asset_name: SqueezeCloud-${{ env.VERSION }}.zip | |
asset_content_type: application/zip |