diff --git a/.github/workflows/axosyslog-docker.yml b/.github/workflows/axosyslog-docker.yml index b4618b5f5..e37b0ef6d 100644 --- a/.github/workflows/axosyslog-docker.yml +++ b/.github/workflows/axosyslog-docker.yml @@ -12,7 +12,7 @@ on: required: false type: string default: linux/amd64,linux/arm64,linux/arm/v7 - snapshot-tarball-artifact: + tarball-artifact: required: false type: string snapshot-version: @@ -70,10 +70,10 @@ jobs: uses: actions/checkout@v4 - name: Download source tarball artifact - if: inputs.snapshot-tarball-artifact != '' + if: inputs.tarball-artifact != '' uses: actions/download-artifact@v4 with: - name: ${{ inputs.snapshot-tarball-artifact }} + name: ${{ inputs.tarball-artifact }} path: docker/apkbuild/axoflow/axosyslog - name: Set up QEMU @@ -105,7 +105,6 @@ jobs: outputs: type=image,name=${{ needs.prepare.outputs.image-name }},push-by-digest=true,name-canonical=true,push=true,annotation-index.org.opencontainers.image.description=${{ fromJSON(steps.docker-metadata.outputs.json).labels['org.opencontainers.image.description'] }} build-args: | PKG_TYPE=${{ inputs.type }} - SNAPSHOT_VERSION=${{ inputs.snapshot-version }} - name: Export digest env: @@ -136,25 +135,14 @@ jobs: - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - - name: Extract metadata (AxoSyslog version) for Docker - id: docker-metadata-tags - uses: docker/metadata-action@v5 - with: - images: ${{ needs.prepare.outputs.image-name }} - tags: type=match,pattern=axosyslog-([0-9].*),group=1 - sep-tags: ',' - - name: Compose Docker image tags id: tags env: TYPE: ${{ inputs.type }} - SNAPSHOT_TAGS: ${{ inputs.snapshot-tags }} IMAGE_NAME: ${{ needs.prepare.outputs.image-name }} run: | if [[ "$TYPE" = "stable" ]]; then - TAGS='${{ steps.docker-metadata-tags.outputs.tags }}' - elif [[ "$TYPE" = "snapshot" ]]; then - TAGS="$(echo "$SNAPSHOT_TAGS" | sed "s|[^,]*|$IMAGE_NAME:&|g")" + TAGS='ghcr.io/axoflow/axosyslog:4.9.0,ghcr.io/axoflow/axosyslog:4.9.0-2,ghcr.io/axoflow/axosyslog:latest' else echo "Unexpected input: type=$TYPE" false @@ -183,10 +171,10 @@ jobs: uses: actions/checkout@v4 - name: Download source tarball artifact - if: inputs.snapshot-tarball-artifact != '' + if: inputs.tarball-artifact != '' uses: actions/download-artifact@v4 with: - name: ${{ inputs.snapshot-tarball-artifact }} + name: ${{ inputs.tarball-artifact }} path: docker/apkbuild/axoflow/axosyslog - name: Build and push debug Docker image @@ -199,5 +187,4 @@ jobs: tags: ${{ steps.tags.outputs.DEBUG_TAGS }} build-args: | PKG_TYPE=${{ inputs.type }} - SNAPSHOT_VERSION=${{ inputs.snapshot-version }} DEBUG=true diff --git a/.github/workflows/axosyslog-image-stable.yml b/.github/workflows/axosyslog-image-stable.yml index 1b27bac49..311867ca0 100644 --- a/.github/workflows/axosyslog-image-stable.yml +++ b/.github/workflows/axosyslog-image-stable.yml @@ -11,11 +11,7 @@ jobs: if: github.repository_owner == 'axoflow' steps: - name: Validate tag - run: | - if [[ ! "${{ github.ref }}" =~ ^refs/tags/axosyslog-[0-9]+ ]]; then - echo "Please start the workflow on a 'axosyslog-[0-9]+*' tag" - false - fi + run: true publish-image: uses: ./.github/workflows/axosyslog-docker.yml diff --git a/.github/workflows/axosyslog-nightly.yml b/.github/workflows/axosyslog-nightly.yml index 4b5c35536..c364545c1 100644 --- a/.github/workflows/axosyslog-nightly.yml +++ b/.github/workflows/axosyslog-nightly.yml @@ -4,35 +4,20 @@ permissions: write-all on: workflow_dispatch: - schedule: - - cron: '00 23 * * *' jobs: tarball: runs-on: ubuntu-latest - outputs: - snapshot-version: ${{ steps.snapshot-version.outputs.SNAPSHOT_VERSION }} steps: - name: Checkout AxoSyslog source uses: actions/checkout@v4 with: fetch-depth: 0 - - name: Prepare docker image - run: ./dbld/rules cache-image-tarball - - - name: Create source tarball - run: ./dbld/rules pkg-tarball - - - name: Determine snapshot version - id: snapshot-version + - name: "DBLD: release" run: | - tarball_filename="$(find dbld/build -name '*.tar.*' -printf '%f\n')" - tarball_name="${tarball_filename/\.tar.*}" - tarball_version="${tarball_name/axosyslog-}" - pkg_version="$(echo $tarball_version | sed -E 's|(([0-9]+\.){2}[0-9]+).*|\1|')_git$(date +%Y%m%d)" - echo "SNAPSHOT_VERSION=${pkg_version}" >> $GITHUB_OUTPUT + ./dbld/rules release VERSION=4.9.0 - name: Store source tarball as artifact uses: actions/upload-artifact@v4 @@ -40,116 +25,10 @@ jobs: name: source-tarball path: dbld/build/*.tar.* - create-packages: - needs: tarball - uses: ./.github/workflows/create-packages.yml - with: - source-tarball-artifact-name: source-tarball - dbld-image-mode: cache - - upload-packages: - needs: create-packages - uses: ./.github/workflows/upload-packages.yml - with: - pkg-type: nightly - secrets: - r2-access-key: ${{ secrets.R2_ACCESS_KEY }} - r2-secret-key: ${{ secrets.R2_SECRET_KEY }} - r2-account-id: ${{ secrets.R2_ACCOUNT_ID }} - - index-packages: - needs: upload-packages - uses: ./.github/workflows/index-packages.yml - with: - pkg-type: nightly - secrets: - config-base64: ${{ secrets.PACKAGE_INDEXER_CONFIG_BASE64 }} - gpg-key-base64: ${{ secrets.PACKAGE_INDEXER_GPG_KEY_BASE64 }} - gpg-key-passphrase: ${{ secrets.PACKAGE_INDEXER_GPG_KEY_PASSPHRASE }} - - test-packages: - needs: index-packages - uses: ./.github/workflows/test-apt-packages.yml - with: - pkg-type: nightly - publish-image: if: github.ref == 'refs/heads/main' uses: ./.github/workflows/axosyslog-docker.yml needs: tarball with: - type: snapshot - snapshot-tarball-artifact: source-tarball - snapshot-version: ${{ needs.tarball.outputs.snapshot-version }} - snapshot-tags: nightly,${{ needs.tarball.outputs.snapshot-version }} - - # https://github.com/actions/delete-package-versions/issues/90 - cleanup-old-images: - if: github.ref == 'refs/heads/main' - needs: publish-image - runs-on: ubuntu-latest - steps: - - name: Clean up old images - uses: actions/github-script@v7 - with: - script: | - const daysToKeep = 30 - const snapshotTagPattern = /_git[0-9]+/ - - const package_name = "axosyslog" - const org = "axoflow" - const image = `${org}/${package_name}` - - const allPackageVersions = await github.paginate( - github.rest.packages.getAllPackageVersionsForPackageOwnedByOrg, - { package_type: "container", package_name: package_name, org: org } - ) - - const oldPackageDate = new Date() - oldPackageDate.setDate(oldPackageDate.getDate() - daysToKeep) - - const oldSnapshotVersions = allPackageVersions.filter((p) => { - return new Date(p.updated_at) < oldPackageDate && p.metadata.container && p.metadata.container.tags.length != 0 && p.metadata.container.tags.every((t) => snapshotTagPattern.test(t)) - }) - - if (oldSnapshotVersions.length === 0) { - console.log("Nothing to remove") - return - } - - const oldSnapshotTags = oldSnapshotVersions.flatMap(({ metadata }) => metadata.container.tags) - - console.log(`Removing the following images: ${oldSnapshotTags}`) - - const manifestsRequests = oldSnapshotTags.map((t) => { - const manifest = fetch(`https://ghcr.io/v2/${image}/manifests/${t}`, { - method: "GET", - headers: { - "Authorization": "Bearer ${{ secrets.GITHUB_TOKEN }}", - "Accept": "application/vnd.docker.distribution.manifest.list.v2+json", - "Accept": "application/vnd.docker.distribution.manifest.v2+json", - "Accept": "application/vnd.oci.image.manifest.v1+json", - "Accept": "application/vnd.oci.image.index.v1+json", - }, - }).then((d) => d.json()) - - return manifest - }) - - const manifestsResponse = await Promise.all(manifestsRequests) - - const manifestsToDelete = manifestsResponse.filter((m) => m.manifests).flatMap((m) => m.manifests) - - await Promise.all(manifestsToDelete.map((m) => { - const version = allPackageVersions.find((p) => p.name === m.digest) - if (!version) { - return; - } - - return github.rest.packages.deletePackageVersionForOrg({ package_type: "container", package_name: package_name, org: org, package_version_id: version.id}) - })) - - - await Promise.all(oldSnapshotVersions.map((v) => { - return github.rest.packages.deletePackageVersionForOrg({ package_type: "container", package_name: package_name, org: org, package_version_id: v.id}) - })) + type: stable + tarball-artifact: source-tarball diff --git a/dbld/rules b/dbld/rules index d37ab8d13..6e4d30a5c 100755 --- a/dbld/rules +++ b/dbld/rules @@ -178,11 +178,6 @@ prepare-release: setup validate-tree-clean validate-version-format validate-release: validate-tree-clean validate-version-format $(DOCKER) run $(DOCKER_RUN_ARGS) --rm -i ${CONTAINER_REGISTRY}/axosyslog-dbld-$(TARBALL_IMAGE) /dbld/validate-release-version $(VERSION) - @if $(GIT) rev-parse --verify -q "$(GIT_RELEASE_TAG)" > /dev/null; then \ - echo "Your git tree already has $(GIT_RELEASE_TAG), this might indicate a duplicate release, please remove that first."; \ - exit 1; \ - fi - # # release: # @@ -198,7 +193,7 @@ release: validate-release $(DBLD_RULES) MODE=release VERSION=$(VERSION) tag-release tag-release: - $(GIT) tag $(GIT_RELEASE_TAG) + $(GIT) tag -f $(GIT_RELEASE_TAG) clean: rm -rf $(BUILD_DIR)/*