diff --git a/.github/act/.actrc b/.github/act/.actrc new file mode 100644 index 00000000..5bb06149 --- /dev/null +++ b/.github/act/.actrc @@ -0,0 +1,3 @@ +--directory ../../ +--env-file .github/act/.env +--secret-file .github/act/.secrets \ No newline at end of file diff --git a/.github/act/.env.example b/.github/act/.env.example new file mode 100644 index 00000000..080e7f0f --- /dev/null +++ b/.github/act/.env.example @@ -0,0 +1 @@ +NO_DOCKER_BUILD=true \ No newline at end of file diff --git a/.github/act/.secrets.example b/.github/act/.secrets.example new file mode 100644 index 00000000..d78a70cf --- /dev/null +++ b/.github/act/.secrets.example @@ -0,0 +1,3 @@ +DOCKER_PASSWORD= +DOCKER_USERNAME= +GITHUB_TOKEN= \ No newline at end of file diff --git a/.github/act/README.md b/.github/act/README.md index bbf7166c..a1aa03b5 100644 --- a/.github/act/README.md +++ b/.github/act/README.md @@ -1,5 +1,11 @@ Testing GH Actions with [ACT] +Need to have credentials in a [`.secrets` file](https://nektosact.com/usage/index.html#secrets), copy and rename [`.secrets.example`](./secrets.example) to `.secrets`, then fill out blank fields. Required for docker/metadata-action to read...something. Fails with `Parameter token or opts.auth is required` if they are not supplied. + +An ENV file can also be made by copy and renaming [`.env.example`](./env.example). Set `NO_DOCKER_BUILD=true` if you only want to test APP_VERSION and docker tags output. + +Run the following **from this directory** to make use of `.actrc` and proper working directoy. + ### Test Branch Push ```shell @@ -7,8 +13,15 @@ act -W '.github/act/actTest.yml' -e '.github/act/actBranchEvent.json' ``` -### Test Tag Push +### Test Tag (Release) Push ```shell act -W '.github/act/actTest.yml' -e '.github/act/actTagEvent.json' ``` + + +### Test Tag (Pre-Release) Push + +```shell +act -W '.github/act/actTest.yml' -e '.github/act/actTagPreEvent.json' +``` diff --git a/.github/act/actBranchEvent.json b/.github/act/actBranchEvent.json index 93425d85..29984061 100644 --- a/.github/act/actBranchEvent.json +++ b/.github/act/actBranchEvent.json @@ -1,4 +1,4 @@ { "ref": "refs/heads/master", - "sha": "e80ad81f051e2ff29e73c0401ad9b89a1b32c3f7" + "sha": "005dae76ab51799d3d55112738e301cb1af0dafd" } diff --git a/.github/act/actTagEvent.json b/.github/act/actTagEvent.json index d916fcfa..7b69a635 100644 --- a/.github/act/actTagEvent.json +++ b/.github/act/actTagEvent.json @@ -1,5 +1,8 @@ { - "ref": "refs/tags/0.8.0", - "ref_name": "0.8.0", - "sha": "0a1a94d9ad4efa373f8d34aace5e7f0a3fff42ad" + "ref": "refs/tags/0.8.4", + "ref_name": "0.8.4", + "before": "0000000000000000000000000000000000000000", + "after": "005dae76ab51799d3d55112738e301cb1af0dafd", + "sha": "005dae76ab51799d3d55112738e301cb1af0dafd", + "base_ref": "refs/heads/master" } diff --git a/.github/act/actTagPreEvent.json b/.github/act/actTagPreEvent.json new file mode 100644 index 00000000..adf853f1 --- /dev/null +++ b/.github/act/actTagPreEvent.json @@ -0,0 +1,8 @@ +{ + "ref": "refs/tags/0.8.5-rc1", + "ref_name": "0.8.5-rc1", + "before": "0000000000000000000000000000000000000000", + "after": "005dae76ab51799d3d55112738e301cb1af0dafd", + "sha": "005dae76ab51799d3d55112738e301cb1af0dafd", + "base_ref": "refs/heads/master" +} diff --git a/.github/act/actTest.yml b/.github/act/actTest.yml index 274508e6..5c86fb90 100644 --- a/.github/act/actTest.yml +++ b/.github/act/actTest.yml @@ -1,6 +1,7 @@ name: Publish Docker image to Dockerhub on: + workflow_dispatch: push: branches: - 'master' @@ -8,7 +9,9 @@ on: - '*.*.*' # don't trigger if just updating docs paths-ignore: - - '**.md' + - 'README.md' + - '.github/**' + - 'flatpak/**' # use release instead of tags once version is correctly parsed # https://github.com/docker/metadata-action/issues/422 # https://github.com/docker/metadata-action/issues/240 @@ -17,16 +20,10 @@ on: jobs: - test: + push_to_registry: name: Build and push container images + if: github.event_name != 'pull_request' runs-on: ubuntu-latest -# strategy: -# fail-fast: false -# matrix: -# include: -# - dockerfile: ./Dockerfile -# suffix: '' -# platforms: 'linux/amd64' steps: - name: Check out the repo uses: actions/checkout@v4 @@ -46,11 +43,6 @@ jobs: echo "COMMIT_SHORT_SHA=$calculatedSha" >> $GITHUB_ENV echo "COMMIT_BRANCH=$branchName" >> $GITHUB_ENV -# - name: Set push event short ref -# run: | -# shortEventRef=${github.event.push.ref:10} -# echo "SHORT_REF=$shortEventRef" >> $GITHUB_ENV - - name: Check App Version env: # use release instead of tags once version is correctly parsed @@ -62,26 +54,38 @@ jobs: run: | echo $APP_VERSION -# - name: Extract metadata (tags, labels) for Docker -# id: meta -# uses: docker/metadata-action@v5 -# with: -# # generate Docker tags based on the following events/attributes -# # https://github.com/docker/metadata-action/issues/247#issuecomment-1511259674 for NOT is default branch, eventually -# tags: | -# type=raw,value=latest,enable={{endsWith(github.ref, 'master')}},suffix=${{ matrix.suffix }} -# type=ref,event=branch,enable=${{ !endsWith(github.ref, 'master') }},suffix=${{ matrix.suffix }} -# type=semver,pattern={{version}},suffix=${{ matrix.suffix }} -# flavor: | -# latest=false + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v5 + with: + # generate Docker tags based on the following events/attributes + # https://github.com/docker/metadata-action/issues/247#issuecomment-1511259674 for NOT is default branch, eventually + tags: | + type=edge + + # maybe re-enable branch-named tags in the futures + #type=ref,event=branch,enable=${{ !endsWith(github.ref, 'master') }} + + # tag non-prelease as latest -- has a higher priority than regular tag so it shows first in registries + type=match,pattern=\d.\d.\d$,priority=901 + + # tag all semver (include pre-release) + type=semver,pattern={{version}} + # flavor: | + # latest=false - name: Set up QEMU uses: docker/setup-qemu-action@v3 + id: qemu + if: ${{ !env.NO_DOCKER_BUILD }} -# - name: Set up Docker Buildx -# uses: docker/setup-buildx-action@v3 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + if: ${{ steps.qemu.outcome == 'success' }} + continue-on-error: true - name: Build and push Docker image + if: ${{ steps.qemu.outcome == 'success' }} env: # use release instead of tags once version is correctly parsed #APP_VERSION: ${{ github.event.release.tag_name }} @@ -95,9 +99,7 @@ jobs: # https://github.com/docker/build-push-action/issues/1026#issue-2041857786 build-args: | APP_BUILD_VERSION=${{env.APP_VERSION}} - file: ${{ matrix.dockerfile }} push: false - tags: mstest:latest - #tags: ${{ steps.meta.outputs.tags }} - #labels: ${{ steps.meta.outputs.labels }} - #platforms: ${{ matrix.platforms }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + platforms: linux/amd64,linux/arm64 diff --git a/.github/workflows/publishImage.yml b/.github/workflows/publishImage.yml index 60e37b4a..b77c2b4f 100644 --- a/.github/workflows/publishImage.yml +++ b/.github/workflows/publishImage.yml @@ -43,16 +43,6 @@ jobs: if: github.event_name != 'pull_request' runs-on: ubuntu-latest needs: test - strategy: - fail-fast: false - matrix: - include: - - dockerfile: ./Dockerfile - suffix: '' - platforms: 'linux/amd64,linux/arm64' -# - dockerfile: ./alpine.Dockerfile -# suffix: '-alpine' -# platforms: 'linux/amd64,linux/arm64' # https://docs.github.com/en/actions/security-guides/automatic-token-authentication#permissions-for-the-github_token permissions: packages: write @@ -95,16 +85,17 @@ jobs: # https://github.com/docker/metadata-action/issues/247#issuecomment-1511259674 for NOT is default branch, eventually tags: | type=edge - type=ref,event=branch,enable=${{ !endsWith(github.ref, 'master') }} + + # maybe re-enable branch-named tags in the futures + #type=ref,event=branch,enable=${{ !endsWith(github.ref, 'master') }} # tag non-prelease as latest -- has a higher priority than regular tag so it shows first in registries - type=semver,pattern={{major}}.{{minor}}.{{patch}},value=latest,priority=901 + type=match,pattern=\d.\d.\d$,priority=901 # tag all semver (include pre-release) type=semver,pattern={{version}} - flavor: | - latest=false -# suffix=${{ matrix.suffix }},onlatest=false + # flavor: | + # latest=false - name: Set up QEMU uses: docker/setup-qemu-action@v3 @@ -126,8 +117,7 @@ jobs: # https://github.com/docker/build-push-action/issues/1026#issue-2041857786 build-args: | APP_BUILD_VERSION=${{env.APP_VERSION}} - file: ${{ matrix.dockerfile }} - push: ${{ !env.ACT}} + push: ${{ !env.ACT }} tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} - platforms: ${{ matrix.platforms }} + platforms: linux/amd64,linux/arm64