Skip to content

Commit

Permalink
reworked pipeline into 2 jobs
Browse files Browse the repository at this point in the history
  • Loading branch information
Rikpat committed Apr 5, 2024
1 parent 4551d9a commit 7a4aa84
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 68 deletions.
106 changes: 39 additions & 67 deletions .github/workflows/build-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,23 @@ jobs:
with:
name: dist
path: dist

- name: Test Build Docker image
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/arm64, linux/amd64
cache-from: type=gha
cache-to: type=gha,mode=max

docker:
name: Build Docker
if: github.event_name != 'pull_request'
name: release
needs: build
runs-on: ubuntu-latest
permissions:
contents: write
packages: write
steps:
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
Expand All @@ -48,66 +60,33 @@ jobs:
id: buildx
uses: docker/setup-buildx-action@v3

- uses: actions/checkout@v4

# Has to be in front of docker, assuming docker build doesn't fail
- name: Bump version and push tag
id: tag_version
uses: mathieudutour/github-tag-action@v6.2
with:
github_token: ${{ secrets.GITHUB_TOKEN }}

- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: |
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=sha,format=long
- uses: actions/checkout@v4
type=sha
type=semver,value=${{ steps.tag_version.outputs.new_tag }}pattern={{version}}
type=semver,value=${{ steps.tag_version.outputs.new_tag }}pattern={{major}}.{{minor}}
type=semver,value=${{ steps.tag_version.outputs.new_tag }}pattern={{major}}
- name: Download a Build Artifact
uses: actions/download-artifact@v4.1.4
with:
name: dist

- name: Build Docker image
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/arm64, linux/amd64
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
outputs: type=oci,dest=/tmp/oci.tar

- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: docker
path: /tmp/oci.tar
outputs:
tags: ${{ steps.meta.outputs.tags }}

release:
name: Create github release and push image
if: github.event_name != 'pull_request'
needs:
- build
- docker
runs-on: ubuntu-latest
permissions:
contents: write
packages: write
steps:
- uses: actions/checkout@v4

- name: Bump version and push tag
id: tag_version
uses: mathieudutour/github-tag-action@v6.2
with:
github_token: ${{ secrets.GITHUB_TOKEN }}

- name: Download a Build Artifact
uses: actions/download-artifact@v4
with:
name: dist
path: dist

- name: Create a GitHub release
uses: ncipollo/release-action@v1
with:
Expand All @@ -117,28 +96,21 @@ jobs:
body: ${{ steps.tag_version.outputs.changelog }}
artifacts: "dist/*"

- name: Download a Build Artifact
uses: actions/download-artifact@v4
with:
name: docker
path: /tmp

- name: Login to ${{ env.REGISTRY }}
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Tag and push docker image
run: |
docker load --input /tmp/oci.tar
IFS=. read -r major minor patch <<< $GIT_TAG
dockerImage = "${DOCKER_TAG%%:sha-*}"
for tag in $major "${major}-${minor}" "${major}-${minor}-${patch}"; do
docker tag $DOCKER_TAG $dockerImage:$tag
done
docker push --all-tags $DOCKER_TAG
env:
DOCKER_TAG: ${{ needs.docker.outputs.tags }}
GIT_TAG: ${{ steps.tag_version.outputs.new_tag }}

# Should be fully cached from build job
- name: Build and Push Docker image
uses: docker/build-push-action@v5
with:
context: .
push: true
platforms: linux/arm64, linux/amd64
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ RUN apk add --no-cache \

ARG TARGETOS TARGETARCH

COPY --chmod="111" ./purevpnwg-${TARGETOS}-${TARGETARCH} /bin/purevpnwg
COPY --chmod="111" dist/purevpnwg-${TARGETOS}-${TARGETARCH} /bin/purevpnwg

ENV PUREVPN_USERNAME=""
ENV PUREVPN_PASSWORD=""
Expand Down

0 comments on commit 7a4aa84

Please sign in to comment.