Skip to content

v0.5.5

v0.5.5 #51

Workflow file for this run

name: CI - Build release asset
on:
release:
types: [published]
jobs:
build:
name: Build OTP ${{ matrix.otp }} | Elixir ${{ matrix.elixir }} | Node ${{ matrix.node }} | OS ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: ['ubuntu-22.04']
otp: ['24.3.3']
elixir: ['1.14.3']
node: ['14.21.3']
steps:
- uses: actions/checkout@v2
- name: Set RELEASE_TAG env
run: echo "RELEASE_TAG=${GITHUB_REF:10}" >> $GITHUB_ENV
- name: Update VERSION file with '${GITHUB_REF:10}'
run: echo -n "${GITHUB_REF:11}" > VERSION
- uses: erlef/setup-beam@v1
with:
otp-version: ${{ matrix.otp }}
elixir-version: ${{ matrix.elixir }}
- uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node }}
- name: Install dependencies
run: |
mix local.rebar --force
mix local.hex --force
mix archive.install hex phx_new
mix deps.get
npm install
- name: Check code format
run: mix format --check-formatted
- name: Run tests
run: mix test
- name: Run dialyzer
run: mix dialyzer --force-check --format dialyxir
- name: Build release
run: |
export SECRET_KEY_BASE=$(MIX_ENV=test mix phx.gen.secret)
mix compile
npm run deploy
mix phx.digest
mix release
env:
MIX_ENV: prod
- name: Build package
id: build_package
run: |
timestamp="`date '+%Y%m%d-%H%M%S'`"
version="$timestamp-`echo $REVISION | cut -c1-8 `"
apppath="$RELEASE_PATH/$APPLICATION"
archive="$APPLICATION-$version.tar.gz"
cp cooperatives.yml $apppath/
echo "$RELEASE_TAG" > $apppath/TAG
echo "$REVISION @ $REF" > $apppath/REVISION
echo "$version @ $REF" > $apppath/VERSION
tar -zcf $archive -C $RELEASE_PATH $APPLICATION
echo "::set-output name=timestamp::$timestamp"
echo "::set-output name=version::$version"
echo "::set-output name=archive::$archive"
echo "Release package built at $archive"
env:
REVISION: ${{ github.sha }}
REF: ${{ github.ref }}
RELEASE_PATH: _build/prod/rel
APPLICATION: coophub
- name: Upload package artifact
uses: actions/upload-artifact@v1
with:
name: coophub-release
path: ${{ steps.build_package.outputs.archive }}
- name: Upload release asset
id: upload_release
uses: actions/upload-release-asset@v1.0.1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: ${{ steps.build_package.outputs.archive }}
asset_name: ${{ steps.build_package.outputs.archive }}
asset_content_type: application/tar+gzip
- name: Dispatch release
uses: peter-evans/repository-dispatch@v1
with:
token: ${{ secrets.REPO_DISPATCH_TOKEN }}
repository: ${{ secrets.REPO_DISPATCH_PATH }}
event-type: coophub-release
client-payload: '{"tag": "${{ env.RELEASE_TAG }}", "ref": "${{ github.ref }}", "sha": "${{ github.sha }}"}'
##########
### Disabled for now, since the branch is protected from direct push
### and it works anyways displaying the right version on the site
##########
# - name: Commit VERSION file
# run: |
# git add VERSION
# git config --local user.name "fiqus-ci"
# git config --local user.email "ci@fiqus.coop"
# git commit -m "Bump to $RELEASE_TAG"
# - name: Push VERSION file
# uses: ad-m/github-push-action@master
# with:
# github_token: ${{ secrets.GITHUB_TOKEN }}
# branch: master
# force: true