release #32
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 | |
permissions: | |
contents: write | |
on: | |
workflow_dispatch: | |
env: | |
app_name: swan | |
jobs: | |
build: | |
strategy: | |
matrix: | |
include: | |
- os: ubuntu-latest | |
platform: linux-amd64 | |
image_arch: amd64 | |
runs-on: ${{ matrix.os }} | |
steps: | |
- name: checkout repository | |
uses: actions/checkout@v4 | |
- name: set up dart SDK | |
uses: dart-lang/setup-dart@v1 | |
- name: get dependencies | |
run: dart pub get | |
- name: build application | |
run: dart compile exe lib/main.dart -o ${{ env.app_name }}_${{ matrix.platform }} | |
- name: upload artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: ${{ env.app_name }}_${{ matrix.platform }} | |
path: ${{ env.app_name }}_${{ matrix.platform }} | |
- name: build docker image | |
if: matrix.image_arch != '' | |
run: | | |
docker buildx create --name builder --use | |
docker buildx build \ | |
--platform ${{ matrix.image_arch }} \ | |
-t ${{ env.app_name }}:${{ github.run_id }}-${{ matrix.platform }} \ | |
-t ${{ env.app_name }}:latest \ | |
--build-arg ARCH=${{ matrix.image_arch }} \ | |
--build-arg BINARY=${{ env.app_name }}_${{ matrix.platform }} \ | |
-f Dockerfile . \ | |
--output type=docker,dest=${{ env.app_name }}_image_${{ matrix.platform }}.tar | |
env: | |
DOCKER_BUILDKIT: 1 | |
- name: upload docker image artifact | |
if: matrix.image_arch != '' | |
uses: actions/upload-artifact@v3 | |
with: | |
name: ${{ env.app_name }}_image_${{ matrix.platform }} | |
path: ${{ env.app_name }}_image_${{ matrix.platform }}.tar | |
create_release: | |
needs: build | |
runs-on: ubuntu-latest | |
steps: | |
- name: checkout repository | |
uses: actions/checkout@v4 | |
- name: download artifacts | |
uses: actions/download-artifact@v3 | |
with: | |
path: artifacts | |
- name: get version | |
run: echo "VERSION=$(date +'%Y-%m-%d-%H-%M-%S')" >> $GITHUB_ENV | |
- name: create release | |
id: create_release | |
uses: softprops/action-gh-release@v1 | |
with: | |
tag_name: ${{ env.VERSION }} | |
files: | | |
./artifacts/${{ env.app_name }}_*/${{ env.app_name }}_* | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |