diff --git a/.github/workflows/create-tag.yaml b/.github/workflows/create-tag.yaml new file mode 100644 index 0000000..69c8ec6 --- /dev/null +++ b/.github/workflows/create-tag.yaml @@ -0,0 +1,24 @@ +name: "Generate Tag" + +on: + workflow_dispatch: + inputs: + version: + description: "Tag Version x.x.x" + required: true + type: string +jobs: + publish: + runs-on: ubuntu-latest + permissions: write-all + steps: + - name: Create Tag + uses: actions/github-script@v6 + with: + script: | + github.rest.git.createRef({ + owner: context.repo.owner, + repo: context.repo.repo, + ref: 'refs/tags/v${{ github.event.inputs.version }}', + sha: context.sha + }) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 475f033..87a0dc1 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -4,7 +4,8 @@ name: Create and publish a Docker image on: push: branches: ["main"] - + tags: + - "v*" # Defines two custom environment variables for the workflow. These are used for the Container registry domain, and a name for the Docker image that this workflow builds. env: REGISTRY: ghcr.io @@ -38,6 +39,12 @@ jobs: uses: docker/metadata-action@v3 with: images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + tags: | + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + type=semver,pattern={{raw}} + type=ref,event=branch + - name: Build and push Docker image uses: docker/build-push-action@v5 with: @@ -48,3 +55,34 @@ jobs: labels: ${{ steps.meta.outputs.labels }} cache-from: type=gha cache-to: type=gha,mode=max + release: + needs: build-and-push-image + name: "Release" + if: github.ref_type == 'tag' + runs-on: "ubuntu-latest" + + steps: + - name: "Determine tag" + run: 'echo "RELEASE_TAG=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV' + + - name: "Create release" + uses: "actions/github-script@v6" + with: + github-token: "${{ secrets.GITHUB_TOKEN }}" + script: | + try { + const response = await github.rest.repos.createRelease({ + draft: false, + generate_release_notes: true, + name: process.env.RELEASE_TAG, + owner: context.repo.owner, + prerelease: false, + repo: context.repo.repo, + tag_name: process.env.RELEASE_TAG, + }); + + core.exportVariable('RELEASE_ID', response.data.id); + core.exportVariable('RELEASE_UPLOAD_URL', response.data.upload_url); + } catch (error) { + core.setFailed(error.message); + } diff --git a/Dockerfile b/Dockerfile index 3570ec2..54fb03d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -33,6 +33,7 @@ RUN mix local.hex --force && \ # set build ENV ENV MIX_ENV="prod" +ENV ERL_AFLAGS="+JPperf true" # install mix dependencies COPY mix.exs mix.lock ./