Skip to content

Commit

Permalink
[WIP] workflows: create release from tag using the tag name
Browse files Browse the repository at this point in the history
Creates a release from a tag and uses the tag name as artifact name.

Changes:

* Zip name changed: incorporates the tag name
* "write" permission requested (needed to create release)
* Runs for tags, not branches
  • Loading branch information
thlehmann-ionos committed Oct 30, 2024
1 parent fcccc0f commit d6eab1b
Showing 1 changed file with 18 additions and 44 deletions.
62 changes: 18 additions & 44 deletions .github/workflows/easycloud-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,18 @@ on:
- '**.ts'
- '**.vue'
push:
branches:
- main
- master
- stable*
- ionos-dev
- ionos-dev30
tags:
- v1*
- v2*
- v3*
- snap-*

env:
TARGET_PACKAGE_NAME: easy-storage.zip
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
PACKAGE_NAME_PREFIX: easy-storage
PACKAGE_NAME_EXTENSION: zip

permissions:
contents: read
contents: write

jobs:
easycloud-build:
Expand Down Expand Up @@ -92,43 +90,19 @@ jobs:
- name: Add config partials
run: make -f IONOS/Makefile add_config_partials

- name: Zip dependencies
run: make -f IONOS/Makefile zip_dependencies TARGET_PACKAGE_NAME=${{ env.TARGET_PACKAGE_NAME }}

- name: Log in to the Container registry
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build package name
run: |
SAFE_REF_NAME=${GITHUB_REF_NAME/\//-}
echo "PACKAGE_NAME=${PACKAGE_NAME_PREFIX}-${SAFE_REF_NAME}.${PACKAGE_NAME_EXTENSION}" >> ${GITHUB_ENV}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
with:
images: "${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}"
- name: Zip dependencies
run: make -f IONOS/Makefile zip_dependencies TARGET_PACKAGE_NAME=${{ env.PACKAGE_NAME }}

- name: Create Dockerfile
run: |
cat >Dockerfile << EOF
FROM busybox as builder
COPY ./${{ env.TARGET_PACKAGE_NAME }} /
WORKDIR /builder
RUN unzip /${{ env.TARGET_PACKAGE_NAME }} -d /builder
FROM scratch
WORKDIR /app
VOLUME /app
COPY --from=builder /builder /app
EOF
- name: Build and push Docker image
uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4
- name: Release
uses: softprops/action-gh-release@v2
if: startsWith(github.ref, 'refs/tags/')
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
files: ${{ env.PACKAGE_NAME }}

- name: Show changes on failure
if: failure()
Expand Down

0 comments on commit d6eab1b

Please sign in to comment.