Skip to content

Fix .readthedocs.yml #1119

Fix .readthedocs.yml

Fix .readthedocs.yml #1119

Workflow file for this run

name: Build
env:
GO_VERSION: "1.20"
ATTACHMENTS: ""
GOPATH: ${{ github.workspace }}
BUCKET: charts.s3sync-service.org
AWS_DEFAULT_REGION: us-east-1
on:
release:
types:
- published
push:
branches:
- master
pull_request:
branches:
- master
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Inject slug/short variables
uses: rlespinasse/[email protected]
- name: Chechout
uses: actions/checkout@v4
with:
path: ./src/github.com/${{ github.repository }}
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: ${{ env.GO_VERSION }}
- name: Install dependencies
run: |
cd ./src/github.com/${{ github.repository }}
go mod download
- name: Run tests
env:
RELEASE_VERSION: ${{ env.GITHUB_REF_SLUG }}
run: |
cd ./src/github.com/${{ github.repository }}
make test
- name: Codecov
uses: codecov/codecov-action@v3
with:
file: ./src/github.com/${{ github.repository }}/cover.out
build:
runs-on: ubuntu-latest
needs: test
strategy:
matrix:
go-os: [darwin, windows, linux, freebsd]
go-arch: [amd64, 386, arm, arm64]
exclude:
# excludes 32 bit architectures for darwin builds
- go-os: darwin
go-arch: 386
- go-os: darwin
go-arch: arm
steps:
- name: Inject slug/short variables
uses: rlespinasse/[email protected]
- name: Chechout
uses: actions/checkout@v4
with:
path: ./src/github.com/${{ github.repository }}
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: ${{ env.GO_VERSION }}
- name: Install dependencies
run: |
cd ./src/github.com/${{ github.repository }}
go mod download
- name: Build
env:
RELEASE_VERSION: ${{ env.GITHUB_REF_SLUG }}
OS: ${{ matrix.go-os }}
GOOS: ${{ matrix.go-os }}
ARCH: ${{ matrix.go-arch }}
GOARCH: ${{ matrix.go-arch }}
run: |
cd ./src/github.com/${{ github.repository }}
make build
- name: Upload artifacts
uses: actions/upload-artifact@v3
if: ${{ github.event_name == 'release' }}
with:
name: s3sync-service-${{ env.GITHUB_REF_SLUG }}
path: ./src/github.com/${{ github.repository }}/s3sync-service-*
docker:
runs-on: ubuntu-latest
if: ${{ github.event_name != 'pull_request' }}
needs: test
strategy:
matrix:
include:
# empty registry for DockerHub
- registry: ""
username: DOCKERHUB_USERNAME
password: DOCKERHUB_TOKEN
base-repo: zmazay/s3sync-service
- registry: quay.io
username: QUAY_USERNAME
password: QUAY_TOKEN
base-repo: quay.io/s3sync-service/s3sync-service
steps:
- name: Inject slug/short variables
uses: rlespinasse/[email protected]
- name: Chechout
uses: actions/checkout@v4
with:
path: ./src/github.com/${{ github.repository }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to registry
uses: docker/login-action@v3
with:
registry: ${{ matrix.registry }}
username: ${{ secrets[matrix.username] }}
password: ${{ secrets[matrix.password] }}
- name: Docker buildx
env:
RELEASE_VERSION: ${{ env.GITHUB_REF_SLUG }}
DOCKER_BASE_REPO: ${{ matrix.base-repo }}
run: |
cd ./src/github.com/${{ github.repository }}
make docker-multi-arch
publish:
runs-on: ubuntu-latest
if: ${{ github.event_name == 'release' }}
needs: build
steps:
- name: Inject slug/short variables
uses: rlespinasse/[email protected]
- name: Chechout
uses: actions/checkout@v4
- name: Download artifacts
uses: actions/download-artifact@v3
with:
name: s3sync-service-${{ env.GITHUB_REF_SLUG }}
path: artifacts/
- name: Upload assets
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
for artifact in $(ls artifacts/*); do ATTACHMENTS="${ATTACHMENTS} -a ${artifact}"; done;
hub release edit -m "" ${{ env.GITHUB_REF_SLUG }} ${ATTACHMENTS}
helm-release:
name: helm-release
runs-on: ubuntu-latest
if: ${{ github.event_name == 'release' }}
needs: docker
steps:
- uses: actions/checkout@v4
- name: Install Helm
run: |
curl https://baltocdn.com/helm/signing.asc | sudo apt-key add -
sudo apt-get install apt-transport-https --yes
echo "deb https://baltocdn.com/helm/stable/debian/ all main" | sudo tee /etc/apt/sources.list.d/helm-stable-debian.list
sudo apt-get update -y
sudo apt-get install helm -y
- name: Install AWS CLI
run: sudo apt-get install awscli -y
- name: Check if version exists
id: version-check
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
run: |
cd charts
version=$(helm show chart ./s3sync-service | grep version | awk '{ print $2 }')
exists=$(aws s3api head-object --bucket ${BUCKET} --key charts/s3sync-service-${version}.tgz || true)
if [ -z "${exists}" ]; then
echo "exists=false" >> $GITHUB_OUTPUT
else
echo "exists=$exists" >> $GITHUB_OUTPUT
fi
- name: Package Helm Chart
if: steps.version-check.outputs.exists != true
run: |
cd charts
helm package s3sync-service -d ./s3sync-service/charts
- name: Get existing index
if: steps.version-check.outputs.exists != true
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
run: |
cd charts
aws s3 cp s3://${BUCKET}/index.yaml ./s3sync-service/index.yaml
- name: Generate new Helm index file
if: steps.version-check.outputs.exists != true
run: |
cd charts
helm repo index s3sync-service --url https://charts.s3sync-service.org/ --merge ./s3sync-service/index.yaml
- name: Upload the charts and index files
if: steps.version-check.outputs.exists != true
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
run: |
cd charts
aws s3 cp ./s3sync-service/index.html s3://${BUCKET}
aws s3 cp ./s3sync-service/index.yaml s3://${BUCKET}
aws s3 sync ./s3sync-service s3://${BUCKET} --exclude "*" --include "charts/*"