Build and release when new app version is out. #145
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: Build and release when new app version is out. | |
on: | |
push: | |
branches: | |
- main | |
- master | |
schedule: | |
- cron: '0 10 * * *' | |
workflow_dispatch: | |
jobs: | |
get-version: | |
runs-on: ubuntu-latest | |
outputs: | |
modified: ${{ steps.git-check.outputs.modified }} | |
release_tag: ${{ steps.build.outputs.REDUCE_RELEASE_TAG }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Fetch release version | |
run: | | |
latest_version=$(curl -sL https://api.github.com/repos/rlabduke/reduce/tags | jq -r ".[0].name") | |
if [[ $latest_version != "null" ]] | |
then | |
echo "$latest_version" > release-versions/reduce-latest.txt | |
fi | |
- name: Check for modified files | |
id: git-check | |
run: echo modified="$([ -z "`git status --porcelain`" ] && echo "false" || echo "true")" >> $GITHUB_OUTPUT | |
- name: Commit latest release version | |
if: steps.git-check.outputs.modified == 'true' | |
run: | | |
git config --global user.name 'github-actions[bot]' | |
git config --global user.email 'github-actions[bot]@users.noreply.github.com' | |
git commit -am "New release version" | |
git push | |
- name: Build the Docker image | |
if: steps.git-check.outputs.modified == 'true' | |
id: build | |
working-directory: . | |
run: | | |
REDUCE_RELEASE_TAG=$(cat release-versions/reduce-latest.txt) | |
echo "REDUCE_RELEASE_TAG=$REDUCE_RELEASE_TAG" >> $GITHUB_OUTPUT | |
docker build . -t reduce --build-arg REDUCE_RELEASE_TAG=$REDUCE_RELEASE_TAG | |
docker create -ti --name reducecontainer reduce bash | |
docker cp reducecontainer:/opt/build/reduce.appimage . | |
- name: Upload artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: build | |
path: reduce.appimage | |
macos: | |
runs-on: macos-latest | |
needs: [get-version] | |
if: needs.get-version.outputs.modified == 'true' | |
strategy: | |
matrix: | |
target: [x86_64, aarch64] | |
steps: | |
- uses: actions/checkout@v4 | |
- run: | | |
bash build_mac.sh ${{ needs.get-version.outputs.release_tag }} | |
cd build && tar czf reduce-macos-${{ matrix.target }}.tar.gz * | |
- name: Upload artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: build | |
path: build/reduce-macos-${{ matrix.target }}.tar.gz | |
release: | |
name: Release | |
runs-on: ubuntu-latest | |
needs: [get-version, macos] | |
if: needs.get-version.outputs.modified == 'true' | |
steps: | |
- uses: actions/download-artifact@v3 | |
with: | |
name: build | |
- uses: ncipollo/release-action@v1 | |
with: | |
allowUpdates: True | |
tag: ${{ needs.get-version.outputs.release_tag }} | |
name: ${{ needs.get-version.outputs.release_tag }} | |
prerelease: False | |
artifacts: 'reduce.appimage,reduce-macos-x86_64.tar.gz,reduce-macos-aarch64.tar.gz' | |
token: ${{ secrets.GITHUB_TOKEN }} |