-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore: replace release workflow #400
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
992d7c7
chore: new release workflow
tomaszbarwicki 7068a06
chore: remove old release workflow
tomaszbarwicki 159d2c6
chore: add copyright header
tomaszbarwicki d9dcc68
feat: add reusable composite action
tomaszbarwicki e22bd8a
fix: download url
tomaszbarwicki File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
# ############################################################################# | ||
# Copyright (c) 2023 Contributors to the Eclipse Foundation | ||
# | ||
# See the NOTICE file(s) distributed with this work for additional | ||
# information regarding copyright ownership. | ||
# | ||
# This program and the accompanying materials are made available under the | ||
# terms of the Apache License, Version 2.0 which is available at | ||
# https://www.apache.org/licenses/LICENSE-2.0. | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
# License for the specific language governing permissions and limitations | ||
# under the License. | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# ############################################################################# | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
permissions: | ||
contents: write | ||
pull-requests: write | ||
name: Create release-automation GitHub Release | ||
env: | ||
APP_NAME: 'release-automation' | ||
|
||
jobs: | ||
prepare-release: | ||
runs-on: ubuntu-latest | ||
outputs: | ||
upload_url: ${{ steps.release.outputs[format('{0}--upload_url', env.APP_NAME)] }} | ||
release_created: ${{ steps.release.outputs[format('{0}--release_created', env.APP_NAME)] }} | ||
version: ${{ steps.release.outputs[format('{0}--major',env.APP_NAME)] }}.${{ steps.release.outputs[format('{0}--minor', env.APP_NAME)] }}.${{ steps.release.outputs[format('{0}--patch', env.APP_NAME)] }} | ||
steps: | ||
- uses: google-github-actions/release-please-action@v4 | ||
name: Prepare release | ||
id: release | ||
with: | ||
path: ${{ env.APP_NAME }} | ||
release-type: go | ||
- uses: actions/checkout@v4 | ||
- name: Tag major and minor versions | ||
if: ${{ steps.release.outputs.release-automation--release_created }} | ||
run: | | ||
git config user.name github-actions[bot] | ||
git config user.email 41898282+github-actions[bot]@users.noreply.github.com | ||
git remote add gh-token "https://${{ secrets.GITHUB_TOKEN }}@github.com/eclipse-tractusx/sig-release.git" | ||
git tag -d v${{ steps.release.outputs[format('{0}--major',env.APP_NAME)] }} || true | ||
git tag -d v${{ steps.release.outputs[format('{0}--major',env.APP_NAME)] }}.${{ steps.release.outputs[format('{0}--minor', env.APP_NAME)] }} || true | ||
git push origin :v${{ steps.release.outputs[format('{0}--major',env.APP_NAME)] }} || true | ||
git push origin :v${{ steps.release.outputs[format('{0}--major',env.APP_NAME)] }}.${{ steps.release.outputs[format('{0}--minor', env.APP_NAME)] }} || true | ||
git tag -a v${{ steps.release.outputs[format('{0}--major',env.APP_NAME)] }} -m "Release v${{ steps.release.outputs.release-automation--major }}" | ||
git tag -a v${{ steps.release.outputs[format('{0}--major',env.APP_NAME)]}}.${{ steps.release.outputs[format('{0}--minor', env.APP_NAME)] }} -m "Release v${{ steps.release.outputs[format('{0}--major',env.APP_NAME)] }}.${{ steps.release.outputs[format('{0}--minor', env.APP_NAME)] }}" | ||
git push origin v${{ steps.release.outputs[format('{0}--major',env.APP_NAME)]}} | ||
git push origin v${{ steps.release.outputs[format('{0}--major',env.APP_NAME)] }}.${{ steps.release.outputs[format('{0}--minor', env.APP_NAME)] }} | ||
build-assets: | ||
if: ${{ needs.prepare-release.outputs.release_created }} | ||
runs-on: ubuntu-latest | ||
needs: prepare-release | ||
strategy: | ||
matrix: | ||
goos: [linux, windows, darwin] | ||
goarch: [amd64] | ||
include: | ||
- goos: darwin | ||
goarch: arm64 | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Set up Go | ||
uses: actions/setup-go@v4 | ||
with: | ||
go-version-file: 'release-automation/go.mod' | ||
- name: Build windows binary | ||
if: ${{ matrix.goos == 'windows' }} | ||
run: env GOOS=${{ matrix.goos }} GOARCH=${{ matrix.goarch }} go build -o ${{ github.workspace }}/bin/${{ env.APP_NAME }}-${{ needs.prepare-release.outputs.version }}-${{ matrix.goos }}-${{ matrix.goarch }}.exe | ||
working-directory: ${{ github.workspace }}/${{ env.APP_NAME }} | ||
- name: Upload windows release assets | ||
if: ${{ matrix.goos == 'windows' }} | ||
uses: actions/upload-release-asset@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
upload_url: ${{ needs.prepare-release.outputs.upload_url }} | ||
asset_path: ${{ github.workspace }}/bin/${{ env.APP_NAME }}-${{ needs.prepare-release.outputs.version }}-${{ matrix.goos }}-${{ matrix.goarch }}.exe | ||
asset_name: ${{ env.APP_NAME }}-${{ needs.prepare-release.outputs.version }}-${{ matrix.goos }}-${{ matrix.goarch }}.exe | ||
asset_content_type: application/octet-stream | ||
- name: Build other binaries | ||
if: ${{ matrix.goos != 'windows' }} | ||
run: env GOOS=${{ matrix.goos }} GOARCH=${{ matrix.goarch }} go build -o ${{ github.workspace }}/bin/${{ env.APP_NAME }}-${{ needs.prepare-release.outputs.version }}-${{ matrix.goos }}-${{ matrix.goarch }} | ||
working-directory: ${{ github.workspace }}/${{ env.APP_NAME }} | ||
- name: Upload other release assets | ||
if: ${{ matrix.goos != 'windows' }} | ||
uses: actions/upload-release-asset@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
upload_url: ${{ needs.prepare-release.outputs.upload_url }} | ||
asset_path: ${{ github.workspace }}/bin/${{ env.APP_NAME }}-${{ needs.prepare-release.outputs.version }}-${{ matrix.goos }}-${{ matrix.goarch }} | ||
asset_name: ${{ env.APP_NAME }}-${{ needs.prepare-release.outputs.version }}-${{ matrix.goos }}-${{ matrix.goarch }} | ||
asset_content_type: application/octet-stream |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# ############################################################################# | ||
# Copyright (c) 2023 Contributors to the Eclipse Foundation | ||
# | ||
# See the NOTICE file(s) distributed with this work for additional | ||
# information regarding copyright ownership. | ||
# | ||
# This program and the accompanying materials are made available under the | ||
# terms of the Apache License, Version 2.0 which is available at | ||
# https://www.apache.org/licenses/LICENSE-2.0. | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
# License for the specific language governing permissions and limitations | ||
# under the License. | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# ############################################################################# | ||
|
||
name: "eclipse-tractusx-quality-checks" | ||
description: "Run quality checks based on the release guidelines" | ||
inputs: | ||
version: | ||
description: The version of the quality checks release to use | ||
required: true | ||
default: "0.1.0" | ||
platform: | ||
description: The platform architecture where the quality checks runs on | ||
required: true | ||
default: "linux-amd64" | ||
|
||
runs: | ||
using: composite | ||
steps: | ||
- name: Download quality checks binary | ||
run: curl -OL https://github.com/eclipse-tractusx/sig-release/releases/download/v${{ inputs.version }}/release-automation-${{ inputs.version }}-${{ inputs.platform }} | ||
shell: bash | ||
|
||
- name: Make binary executable | ||
run: chmod +x ./release-automation-${{ inputs.version }}-${{ inputs.platform }} | ||
shell: bash | ||
|
||
- name: Run quality checks | ||
run: ./release-automation-${{ inputs.version }}-${{ inputs.platform }} checkLocal | ||
shell: bash |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @tomaszbarwicki,
could you please explain, why this manual tagging is necessary, when using the release-please action?
You can have a look at this example: https://github.com/catenax-ng/release-automation-playground/blob/main/.github/workflows/release.yaml#L24
There is almost no manual step necessary except the building an uploading.
I think having this in a single job is maybe also easier than having two jobs and then needing to set outputs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @SebastianBezold,
the reason of creating tags is because we want as I believe to use release-automation as GitHub action, replacing following: https://github.com/eclipse-tractusx/sig-infra/blob/main/.github/workflows/reusable-quality-checks.yaml therefore we need to create appropriate tags as suggested by
https://github.com/google-github-actions/release-please-action#creating-majorminor-tags
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah ok I see! makes sense in our case of releasing the action as well in the same repo.
I think i saw a feature of release-please, that would allow us to replace the version number of the action with the outputs of release please too. Maybe this would be a good next step then, since it feels odd, that we only need that for the action.yaml file, which we might forget to increment in the PR.
In such cases, we would tag the commit, but would create a following commit, that then bumps the version used in the action. Could lead to the action being behind one version always :)