Skip to content

feat(downloadLimit): release download limit feature - close #2 #75

feat(downloadLimit): release download limit feature - close #2

feat(downloadLimit): release download limit feature - close #2 #75

Workflow file for this run

name: Docker Image CI
on:
push:
branches: [ "main" ]
paths: ["**", "!docs/**", "!README.md", "!LICENSE", "!.husky/**", "!.local/**", "!.github/workflows/docs.yml"]
workflow_dispatch:
# Allow one concurrent deployment
concurrency:
group: "docker-image"
cancel-in-progress: true
jobs:
source:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
- uses: actions/setup-node@v4
with:
node-version-file: 'app/web/package.json'
- name: Install front-end javascript utilities
run: cd app/web && npm ci && npm audit signatures # some directories in node_modules are embedded in Go binary
- name: Install go dependencies
run: go mod download
- name: Upload source and installed dependencies
uses: actions/upload-artifact@v4
with:
name: source
path: |
./
!test/
if-no-files-found: error
commitlint-version:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-node@v4
with:
node-version-file: 'package.json'
- name: Install tooling
run: npm ci && npm audit signatures
- name: Verify last commit
run: npm run commitlint -- --from=HEAD~1 --to HEAD --verbose
- name: Calculate & set version file
run: touch VERSION && npx commit-and-tag-version
- name: Output version & commit
id: out
run: |
echo "version=$(cat VERSION)" >> "$GITHUB_OUTPUT"
echo "commit=$(git rev-parse --short HEAD)" >> "$GITHUB_OUTPUT"
outputs:
version: ${{ steps.out.outputs.version }}
commit: ${{ steps.out.outputs.commit }}
lint:
runs-on: ubuntu-22.04
needs: source
steps:
- uses: actions/download-artifact@v4
with:
name: source
- uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: v1.55.2
unit-test:
runs-on: ubuntu-22.04
needs: source
steps:
- uses: actions/download-artifact@v4
with:
name: source
- uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
- name: Run unit tests
run: go test ./...
build:
runs-on: ubuntu-22.04
needs: [source,commitlint-version]
steps:
- uses: actions/download-artifact@v4
with:
name: source
- uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
- name: Build go binary
env:
VERSION: ${{needs.commitlint-version.outputs.version}}
COMMIT: ${{needs.commitlint-version.outputs.commit}}
run: |
echo "Building app version $VERSION candidate with git commit $COMMIT"
CGO_ENABLED=0 GOARCH=amd64 GOOS=linux go build -ldflags="-s -w -X main.build=v$VERSION-$COMMIT" -o ./binary ./cmd/main.go
- uses: docker/setup-buildx-action@v3
- name: Build release image candidate
uses: docker/build-push-action@v5
with:
context: .
file: ./.github/workflows/Dockerfile
outputs: type=docker,dest=/tmp/app-candidate-image.tar
tags: blinkfile-candidate
- name: Upload app image candidate artifact
uses: actions/upload-artifact@v4
with:
name: app-candidate-image
path: /tmp/app-candidate-image.tar
compression-level: 0
if-no-files-found: error
acceptance-test-source:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- name: Upload source and installed dependencies
uses: actions/upload-artifact@v4
with:
name: acceptance-test-source
path: test/
if-no-files-found: error
acceptance-test:
runs-on: ubuntu-22.04
needs: [build,acceptance-test-source]
steps:
- uses: actions/download-artifact@v4
with:
name: app-candidate-image
path: /tmp
- name: Load app image candidate
run: docker load --input /tmp/app-candidate-image.tar
- uses: actions/download-artifact@v4
with:
name: acceptance-test-source
- uses: docker/setup-buildx-action@v3
- name: Build acceptance-test runner image
uses: docker/build-push-action@v5
with:
context: ./cypress
load: true
tags: blinkfile-acceptance-test-runner
cache-from: type=gha
cache-to: type=gha
- name: Run acceptance tests
run: docker compose up --exit-code-from acceptance-test-runner
deploy:
runs-on: ubuntu-22.04
permissions:
contents: write
needs: [commitlint-version,lint,unit-test,build,acceptance-test]
steps:
- uses: actions/download-artifact@v4
with:
name: app-candidate-image
path: /tmp
- name: Load app image candidate
run: docker load --input /tmp/app-candidate-image.tar
- name: Docker login
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Tag image
env:
VERSION: ${{needs.commitlint-version.outputs.version}}
COMMIT: ${{needs.commitlint-version.outputs.commit}}
run: |
MAJOR=$(echo $VERSION | cut -d. -f1)
MINOR=$(echo $VERSION | cut -d. -f2)
docker tag blinkfile-candidate benjohns1/blinkfile:latest
docker tag blinkfile-candidate benjohns1/blinkfile:$VERSION
docker tag blinkfile-candidate benjohns1/blinkfile:$MAJOR
docker tag blinkfile-candidate benjohns1/blinkfile:$MAJOR.$MINOR
docker tag blinkfile-candidate benjohns1/blinkfile:$VERSION-$COMMIT
- uses: actions/checkout@v4
- name: Push git tag
env:
VERSION: ${{needs.commitlint-version.outputs.version}}
run: |
git config user.name "GitHub Actions"
git config user.email "github-actions@users.noreply.github.com"
git tag -a v$VERSION -m "Release version $VERSION"
git push origin v$VERSION
- name: Push image
run: docker push -a benjohns1/blinkfile